Skip to content

Commit adf1504

Browse files
committed
Makes sure SDK still works after loading bad bundles.
1 parent 556a007 commit adf1504

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/firestore/src/core/sync_engine.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@ export class SyncEngine implements RemoteSyncer {
449449

450450
return (
451451
this.loadBundleAsync(bundleReader, task)
452-
// TODO(wuandy): Loading a bundle will fail the entire SDK if there is
453-
// an error. We really should have a way to run operations on async queue
454-
// and not failing the rest if there is an error.
455452
.catch(reason => {
456453
task.failedWith(reason);
457454
})

packages/firestore/test/integration/api/bundle.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,31 @@ apiDescribe('Bundles', (persistence: boolean) => {
226226

227227
it('load with documents from other projects fails.', () => {
228228
return withTestDb(persistence, async db => {
229-
const builder = bundleWithTestDocs(db);
229+
let builder = bundleWithTestDocs(db);
230230
return withAlternateTestDb(persistence, async otherDb => {
231231
// eslint-disable-next-line @typescript-eslint/no-floating-promises
232232
expect(
233233
otherDb.loadBundle(
234234
builder.build('test-bundle', { seconds: 1001, nanos: 9999 })
235235
)
236236
).to.be.rejectedWith('Tried to deserialize key from different project');
237+
238+
// Verify otherDb still functions, despite loaded a problematic bundle.
239+
builder = bundleWithTestDocs(otherDb);
240+
const progress = await otherDb.loadBundle(
241+
builder.build('test-bundle', { seconds: 1001, nanos: 9999 })
242+
);
243+
verifySuccessProgress(progress);
244+
245+
// Read from cache. These documents do not exist in backend, so they can
246+
// only be read from cache.
247+
const snap = await otherDb
248+
.collection('coll-1')
249+
.get({ source: 'cache' });
250+
expect(toDataArray(snap)).to.deep.equal([
251+
{ k: 'a', bar: 1 },
252+
{ k: 'b', bar: 2 }
253+
]);
237254
});
238255
});
239256
});

0 commit comments

Comments
 (0)