-
Notifications
You must be signed in to change notification settings - Fork 946
Remove unused code #2817
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
Remove unused code #2817
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google Inc. | ||
* Copyright 2017 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -118,18 +118,4 @@ export class TargetData { | |
this.resumeToken | ||
); | ||
} | ||
|
||
isEqual(other: TargetData): boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't I worry that we may have tests that are checking that something is not equal that are now accidentally passing while checking reference equality. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TargetData was never passed to our custom "equals" implementation. I actually looked back at the usage and since there is only one call, I decided to inline it. So now we have no code that treats objects with isEqual and without in the same codepath. |
||
return ( | ||
this.targetId === other.targetId && | ||
this.purpose === other.purpose && | ||
this.sequenceNumber === other.sequenceNumber && | ||
this.snapshotVersion.isEqual(other.snapshotVersion) && | ||
this.lastLimboFreeSnapshotVersion.isEqual( | ||
other.lastLimboFreeSnapshotVersion | ||
) && | ||
this.resumeToken.isEqual(other.resumeToken) && | ||
this.target.isEqual(other.target) | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -289,15 +289,6 @@ export class AsyncQueue { | |||
const message = error.stack || error.message || ''; | ||||
logError('INTERNAL UNHANDLED ERROR: ', message); | ||||
|
||||
// Escape the promise chain and throw the error globally so that | ||||
// e.g. any global crash reporting library detects and reports it. | ||||
// (but not for simulated errors in our tests since this breaks mocha) | ||||
if (message.indexOf('Firestore Test Simulated Error') < 0) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still used, isn't it?
You mentioned in the PR description that you ran the integration tests... did you run the unit tests also? Because it seems like the unit tests should fail with this line removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is special handling of test code that is no longer needed, since we are not using As for running the unit tests - all tests run as part of CI, and I usually run them locally as well. There are some tests that are "harder" to run locally, such as the minified integration tests (see /integration/firestore), but even those are run in CI. |
||||
setTimeout(() => { | ||||
throw error; | ||||
}, 0); | ||||
} | ||||
|
||||
// Re-throw the error so that this.tail becomes a rejected Promise and | ||||
// all further attempts to chain (via .then) will just short-circuit | ||||
// and return the rejected Promise. | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my own information, is it acceptable to delete exported functions as long as they are not "publicly exported" in https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore-types/index.d.ts? Otherwise, wouldn't this be a backwards-incompatible change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, if code is not in the api/ folder, it can't be used by our users.
In more technical terms, only code that is exported from our index.ts files is considered part of the public API:
https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/register-module.ts
Furthermore, the files under /api should match our types (https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore-types/index.d.ts). All code in the exported classes above should either be part of the public API or prefixed with an underscore. We don't always get this right though - see https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/api/database.ts#L653.
logLevel
is not in our types, but can be accessed since it is exported as part of Firestore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does removing this actually help? It seems like this should have been tree-shaken out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Tree-Shaking in the browser builds doesn't actually work very well. I am trying to fix that (currently not working though - #2829), but for the "older builds" only excludes code that in modules that aren't loaded at all. Only the ESM2017 build will not include functions, but also only if they are deemed "side-effect free".