Skip to content

Adding experimentalAutoDetectLongPolling #3724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
33d69f3
Upgrade to latest version of closure
rafikhan Jul 8, 2020
35d4713
Adding changeset
rafikhan Jul 8, 2020
d24a58f
Updating changeset message
rafikhan Jul 8, 2020
6084312
Fixing stylization in changeset copy
rafikhan Jul 8, 2020
a2a8817
Merge branch 'master' into khanrafi/webchannelupgrade
rafikhan Jul 9, 2020
433c8ba
Merge branch 'master' into khanrafi/webchannelupgrade
rafikhan Jul 10, 2020
4f544d8
WIP
rafikhan Jul 31, 2020
e778894
Merge branch 'master' into khanrafi/webchannelupgrade
rafikhan Jul 31, 2020
cffed37
Merge branch 'master' of github.com:firebase/firebase-js-sdk into kha…
rafikhan Sep 1, 2020
bb5fe2c
Updating to match new patterns
rafikhan Sep 1, 2020
59c8900
Making member names match conventions on others
rafikhan Sep 1, 2020
dbffc65
Making the linter happy
rafikhan Sep 1, 2020
bee717c
Fixing bug caught by unit tests and misc polish
rafikhan Sep 1, 2020
7356673
Turning auto detection on by default
rafikhan Sep 1, 2020
14887c4
Turning auto detection on by default
rafikhan Sep 1, 2020
66ed0bf
Merge branch 'khanrafi/webchannelupgrade' of github.com:firebase/fire…
rafikhan Sep 1, 2020
fb6a370
Update packages/firestore/src/util/input_validation.ts
rafikhan Sep 8, 2020
458c75a
Update packages/firebase/index.d.ts
rafikhan Sep 9, 2020
ecd8469
Changing default to false
rafikhan Sep 9, 2020
3c34f6d
Fixing grammar
rafikhan Sep 9, 2020
c26a7ec
Merge branch 'master' into khanrafi/webchannelupgrade
rafikhan Sep 22, 2020
f9859a9
Adding integration test
rafikhan Sep 29, 2020
1d8d8c3
Undoing formatting changes
rafikhan Sep 29, 2020
5222ae7
Resetting hard code to false
rafikhan Sep 29, 2020
9f756ad
Update packages/firestore/src/core/database_info.ts
rafikhan Sep 29, 2020
94095b7
Update packages/firestore/test/integration/api/database.test.ts
rafikhan Sep 29, 2020
500b3d9
Create yellow-turkeys-lay.md
rafikhan Sep 29, 2020
2eeffd2
Update .changeset/yellow-turkeys-lay.md
rafikhan Sep 30, 2020
490c0ef
Update .changeset/yellow-turkeys-lay.md
rafikhan Sep 30, 2020
ed94332
Update index.d.ts
rafikhan Oct 6, 2020
1b10fb5
Update yellow-turkeys-lay.md
rafikhan Oct 6, 2020
64fa5fb
Merge branch 'master' of github.com:firebase/firebase-js-sdk into kha…
rafikhan Oct 7, 2020
c972e4c
Updating unit test to contain proper error string
rafikhan Oct 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions integration/messaging/test/test-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ describe('Starting Integration Test > Sending and Receiving ', function () {
}

TEST_DOMAINS.forEach(domain => {
describe(`Testing browser: ${assistantBrowser.getPrettyName()} : ${domain}`, function() {
before(async function() {
describe(`Testing browser: ${assistantBrowser.getPrettyName()} : ${domain}`, function () {
before(async function () {
globalWebDriver = createPermittedWebDriver(
/* browser= */ assistantBrowser.getId()
);
});

it('Background app can receive a {} empty message from sw', async function() {
it('Background app can receive a {} empty message from sw', async function () {
this.timeout(TIMEOUT_BACKGROUND_MESSAGE_TEST_UNIT_MILLISECONDS);

// Clearing the cache and db data by killing the previously instantiated driver. Note that
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Starting Integration Test > Sending and Receiving ', function () {
);
});

it('Background app can receive a {"data"} message frow sw', async function() {
it('Background app can receive a {"data"} message frow sw', async function () {
this.timeout(TIMEOUT_BACKGROUND_MESSAGE_TEST_UNIT_MILLISECONDS);

await seleniumAssistant.killWebDriver(globalWebDriver);
Expand Down Expand Up @@ -135,7 +135,6 @@ describe('Starting Integration Test > Sending and Receiving ', function () {
/* expectedDataPayload= */ getTestDataPayload()
);
});

});

it('Foreground app can receive a {} empty message in onMessage', async function () {
Expand Down
20 changes: 16 additions & 4 deletions packages/firebase/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7879,15 +7879,27 @@ declare namespace firebase.firestore {
* buffer traffic indefinitely. Use of this option will cause some
* performance degradation though.
*
* This setting may be removed in a future release. If you find yourself
* using it to work around a specific network reliability issue, please
* tell us about it in
* https://github.com/firebase/firebase-js-sdk/issues/1674.
* This setting cannot be used with experimentalAutoDetectLongPolling and
* may be removed in a future release. If you find yourself using it to
* work around a specific network reliability issue, please tell us about
* it in https://github.com/firebase/firebase-js-sdk/issues/1674.
*
* @webonly
*/
experimentalForceLongPolling?: boolean;

/**
* Configures the SDK's underlying transport (WebChannel) to automatically detect if
* long-polling should be used and also update as the networking conditions change. This is
* very similar to experimentalForceLongPolling but does automatic detection.
*
* This setting cannot be used with experimentalForceLongPolling and may be removed in a future
* release.
*
* @webonly
*/
experimentalAutoDetectLongPolling?: boolean;

/**
* Whether to skip nested properties that are set to `undefined` during
* object serialization. If set to `true`, these properties are skipped
Expand Down
1 change: 1 addition & 0 deletions packages/firestore-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Settings {
timestampsInSnapshots?: boolean;
cacheSizeBytes?: number;
experimentalForceLongPolling?: boolean;
experimentalAutoDetectLongPolling?: boolean;
ignoreUndefinedProperties?: boolean;
merge?: boolean;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/exp/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export class Firestore
this._persistenceKey,
settings.host ?? DEFAULT_HOST,
settings.ssl ?? DEFAULT_SSL,
/* forceLongPolling= */ false
/* forceLongPolling= */ false,
/* forceAutoDetectLongPolling= */ true
);
return {
asyncQueue: this._queue,
Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/exp/src/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import { Transaction as InternalTransaction } from '../../../src/core/transactio
import { validateReference } from '../../../lite/src/api/write_batch';
import { getDatastore } from '../../../lite/src/api/components';

export class Transaction extends LiteTransaction
export class Transaction
extends LiteTransaction
implements firestore.Transaction {
// This class implements the same logic as the Transaction API in the Lite SDK
// but is subclassed in order to return its own DocumentSnapshot types.
Expand Down
3 changes: 2 additions & 1 deletion packages/firestore/lite/src/api/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function getDatastore(firestore: Firestore): Datastore {
firestore._persistenceKey,
settings.host ?? DEFAULT_HOST,
settings.ssl ?? DEFAULT_SSL,
/* forceLongPolling= */ false
/* forceLongPolling= */ false,
/* forceAutoDetectLongPolling= */ true
);

const connection = newConnection(databaseInfo);
Expand Down
187 changes: 185 additions & 2 deletions packages/firestore/scripts/build-bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';
/**
* @license
* Copyright 2020 Google LLC
Expand All @@ -14,4 +14,187 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P((function(resolve){resolve(value)}))}return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};exports.__esModule=true;var yargs=require("yargs");var rollup_1=require("rollup");var typescriptPlugin=require("rollup-plugin-typescript2");var alias=require("@rollup/plugin-alias");var json=require("rollup-plugin-json");var util=require("../rollup.shared");var argv=yargs.options({input:{type:"string",demandOption:true,desc:"The location of the index.ts file"},output:{type:"string",demandOption:true,desc:"The location for the transpiled JavaScript bundle"}}).argv;function buildBundle(input,output){return __awaiter(this,void 0,void 0,(function(){var bundle;return __generator(this,(function(_a){switch(_a.label){case 0:return[4,rollup_1.rollup({input:input,plugins:[alias(util.generateAliasConfig("node")),typescriptPlugin({tsconfigOverride:{compilerOptions:{target:"es2017"}},transformers:[util.removeAssertTransformer]}),json({preferConst:true})],external:util.resolveNodeExterns})];case 1:bundle=_a.sent();return[4,bundle.write({file:output,format:"es"})];case 2:_a.sent();return[2]}}))}))}buildBundle(argv.input,argv.output);
*/ var __awaiter =
(this && this.__awaiter) ||
function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P
? value
: new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator['throw'](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done
? resolve(result.value)
: adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator =
(this && this.__generator) ||
function (thisArg, body) {
var _ = {
label: 0,
sent: function () {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
},
f,
y,
t,
g;
return (
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
typeof Symbol === 'function' &&
(g[Symbol.iterator] = function () {
return this;
}),
g
);
function verb(n) {
return function (v) {
return step([n, v]);
};
}
function step(op) {
if (f) throw new TypeError('Generator is already executing.');
while (_)
try {
if (
((f = 1),
y &&
(t =
op[0] & 2
? y['return']
: op[0]
? y['throw'] || ((t = y['return']) && t.call(y), 0)
: y.next) &&
!(t = t.call(y, op[1])).done)
)
return t;
if (((y = 0), t)) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) &&
(op[0] === 6 || op[0] === 2)
) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2]) _.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
if (op[0] & 5) throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
};
exports.__esModule = true;
var yargs = require('yargs');
var rollup_1 = require('rollup');
var typescriptPlugin = require('rollup-plugin-typescript2');
var alias = require('@rollup/plugin-alias');
var json = require('rollup-plugin-json');
var util = require('../rollup.shared');
var argv = yargs.options({
input: {
type: 'string',
demandOption: true,
desc: 'The location of the index.ts file'
},
output: {
type: 'string',
demandOption: true,
desc: 'The location for the transpiled JavaScript bundle'
}
}).argv;
function buildBundle(input, output) {
return __awaiter(this, void 0, void 0, function () {
var bundle;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
return [
4,
rollup_1.rollup({
input: input,
plugins: [
alias(util.generateAliasConfig('node')),
typescriptPlugin({
tsconfigOverride: { compilerOptions: { target: 'es2017' } },
transformers: [util.removeAssertTransformer]
}),
json({ preferConst: true })
],
external: util.resolveNodeExterns
})
];
case 1:
bundle = _a.sent();
return [4, bundle.write({ file: output, format: 'es' })];
case 2:
_a.sent();
return [2];
}
});
});
}
buildBundle(argv.input, argv.output);
58 changes: 56 additions & 2 deletions packages/firestore/scripts/extract-api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';
/**
* @license
* Copyright 2020 Google LLC
Expand All @@ -14,4 +14,58 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/exports.__esModule=true;exports.extractPublicIdentifiers=void 0;var ts=require("typescript");var fs=require("fs");function extractIdentifiersFromNodeAndChildren(node,symbols){if(ts.isIdentifier(node)){symbols.add(node.escapedText.toString())}ts.forEachChild(node,(function(childNode){return extractIdentifiersFromNodeAndChildren(childNode,symbols)}))}function extractTypeDeclaration(fileName){var result;var compilerOptions={declaration:true,emitDeclarationOnly:true};var host=ts.createCompilerHost(compilerOptions);host.writeFile=function(_,contents){return result=contents};var program=ts.createProgram([fileName],compilerOptions,host);program.emit();return result}function extractPublicIdentifiers(filePaths){var publicIdentifiers=new Set;var _loop_1=function(filePath){var contents=fs.readFileSync(filePath,{encoding:"utf-8"});var sourceFile=ts.createSourceFile(filePath,contents,ts.ScriptTarget.ES2015);if(!sourceFile.isDeclarationFile){var dtsSource=extractTypeDeclaration(filePath);sourceFile=ts.createSourceFile(filePath.replace(".ts",".d.ts"),dtsSource,ts.ScriptTarget.ES2015)}var identifiers=new Set;ts.forEachChild(sourceFile,(function(childNode){return extractIdentifiersFromNodeAndChildren(childNode,identifiers)}));identifiers.forEach((function(api){publicIdentifiers.add(api)}))};for(var _i=0,filePaths_1=filePaths;_i<filePaths_1.length;_i++){var filePath=filePaths_1[_i];_loop_1(filePath)}return publicIdentifiers}exports.extractPublicIdentifiers=extractPublicIdentifiers;
*/ exports.__esModule = true;
exports.extractPublicIdentifiers = void 0;
var ts = require('typescript');
var fs = require('fs');
function extractIdentifiersFromNodeAndChildren(node, symbols) {
if (ts.isIdentifier(node)) {
symbols.add(node.escapedText.toString());
}
ts.forEachChild(node, function (childNode) {
return extractIdentifiersFromNodeAndChildren(childNode, symbols);
});
}
function extractTypeDeclaration(fileName) {
var result;
var compilerOptions = { declaration: true, emitDeclarationOnly: true };
var host = ts.createCompilerHost(compilerOptions);
host.writeFile = function (_, contents) {
return (result = contents);
};
var program = ts.createProgram([fileName], compilerOptions, host);
program.emit();
return result;
}
function extractPublicIdentifiers(filePaths) {
var publicIdentifiers = new Set();
var _loop_1 = function (filePath) {
var contents = fs.readFileSync(filePath, { encoding: 'utf-8' });
var sourceFile = ts.createSourceFile(
filePath,
contents,
ts.ScriptTarget.ES2015
);
if (!sourceFile.isDeclarationFile) {
var dtsSource = extractTypeDeclaration(filePath);
sourceFile = ts.createSourceFile(
filePath.replace('.ts', '.d.ts'),
dtsSource,
ts.ScriptTarget.ES2015
);
}
var identifiers = new Set();
ts.forEachChild(sourceFile, function (childNode) {
return extractIdentifiersFromNodeAndChildren(childNode, identifiers);
});
identifiers.forEach(function (api) {
publicIdentifiers.add(api);
});
};
for (var _i = 0, filePaths_1 = filePaths; _i < filePaths_1.length; _i++) {
var filePath = filePaths_1[_i];
_loop_1(filePath);
}
return publicIdentifiers;
}
exports.extractPublicIdentifiers = extractPublicIdentifiers;
Loading