Skip to content

Commit 0a40485

Browse files
committed
update
1 parent 7f7adb1 commit 0a40485

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.changeset/cyan-rats-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/messaging': patch
3+
---
4+
5+
Revised token update logic to keep existing token

packages/messaging/src/internals/token-manager.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,27 @@ describe('Token Manager', () => {
133133
tokenDetails.createTime = Date.now() - 8 * 24 * 60 * 60 * 1000; // 8 days ago, triggering an update
134134
await dbSet(messaging.firebaseDependencies, tokenDetails);
135135
requestUpdateTokenStub.rejects(new Error('Temporary server error'));
136-
136+
137137
// Act
138-
await expect(getTokenInternal(messaging)).to.be.rejectedWith('Temporary server error');
139-
138+
await expect(getTokenInternal(messaging)).to.be.rejectedWith(
139+
'Temporary server error'
140+
);
141+
140142
// Assert
141143
expect(requestUpdateTokenStub).to.have.been.called;
142144
expect(requestDeleteTokenStub).not.to.have.been.called; // Verify delete was not called
143-
145+
144146
// Reasoning documentation
145147
// This test ensures that the token is not deleted upon an update failure,
146148
// recognizing that such failures may be temporary server-side issues.
147149
// By not deleting the token, we allow the system to retry the update in the future,
148150
// avoiding unnecessary token churn and preserving continuity for the user.
149-
151+
150152
const tokenFromDb = await dbGet(messaging.firebaseDependencies);
151153
expect(tokenFromDb).to.not.be.null; // Ensure the token still exists
152154
});
153-
155+
});
156+
154157
describe('deleteToken', () => {
155158
it('returns if there is no token in the db', async () => {
156159
await deleteTokenInternal(messaging);

0 commit comments

Comments
 (0)