fix(offline-channel): Add missing return after reject() to prevent null provider dereference#2734
Open
hectorhdzg wants to merge 1 commit into
Open
Conversation
…ll provider dereference In OfflineBatchHandler.ts, the storeBatch, sendNextBatch, hasStoredBatch, and cleanStorage methods call reject() when the provider is null/undefined but do not return, causing execution to continue and attempt to use the null provider. This results in a runtime null dereference error in the offline recovery path. Added return statements after each reject() call to short-circuit execution. Added unit tests verifying all four methods properly reject without throwing when the provider is unavailable.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a null dereference bug in OfflineBatchHandler where four methods (storeBatch, sendNextBatch, hasStoredBatch, cleanStorage) would call reject() when the provider was unavailable but continue executing, attempting to dereference the null provider on the subsequent line.
Changes:
- Added
returnstatements after eachreject(new Error(NoProviderErrMsg))call in the four affected methods. - Added semicolons to three previously missing statement terminators.
- Added four unit tests verifying each method rejects cleanly without throwing when the provider is null.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| channels/offline-channel-js/src/OfflineBatchHandler.ts | Added missing return after reject() in four methods to prevent null provider dereference. |
| channels/offline-channel-js/Tests/Unit/src/offlinebatchhandler.tests.ts | Added four unit tests covering the null-provider rejection paths. |
MSNev
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In OfflineBatchHandler.ts, the storeBatch, sendNextBatch, hasStoredBatch, and cleanStorage methods call reject() when the provider is null/undefined but do not return, causing execution to continue and attempt to use the null provider. This results in a runtime null dereference error in the offline recovery path.
Added return statements after each reject() call to short-circuit execution. Added unit tests verifying all four methods properly reject without throwing when the provider is unavailable.