-
Notifications
You must be signed in to change notification settings - Fork 31
fix: Fix an issue where failed http requests could cause an unhandled promise rejection. #371
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
Conversation
|
This pull request has been linked to Shortcut Story #232944: LaunchDarkly node-server-sdk is crashing node process due to unhandled promise. |
| expect(serverResult.headers['sample-header']).toEqual('Some header value'); | ||
| }); | ||
|
|
||
| it('rejection is handled for response even if not awaited', async () => { |
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.
Running this test against the original code will fail, against this code it works.
|
|
||
| status: number; | ||
|
|
||
| listened: boolean = false; |
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.
Basically we don't attempt to read the body from all HTTP requests we make. Event posting doesn't return a body, so we discard the inner response.
Unfortunately that inner response may still be rejected.
So we track if the promise has been listened to. If it has been, then we reject like normal. If not we cache the rejection error and throw it when someone listens to the promise.
🤖 I have created a release *beep* *boop* --- <details><summary>node-server-sdk: 9.1.1</summary> ## [9.1.1](node-server-sdk-v9.1.0...node-server-sdk-v9.1.1) (2024-02-08) ### Bug Fixes * Fix an issue where failed http requests could cause an unhandled promise rejection. ([#371](#371)) ([dd6d0e7](dd6d0e7)) </details> <details><summary>node-server-sdk-dynamodb: 6.1.1</summary> ## [6.1.1](node-server-sdk-dynamodb-v6.1.0...node-server-sdk-dynamodb-v6.1.1) (2024-02-08) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.1.0 to 9.1.1 * peerDependencies * @launchdarkly/node-server-sdk bumped from 9.0.6 to 9.1.1 </details> <details><summary>node-server-sdk-redis: 4.1.1</summary> ## [4.1.1](node-server-sdk-redis-v4.1.0...node-server-sdk-redis-v4.1.1) (2024-02-08) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/node-server-sdk bumped from 9.1.0 to 9.1.1 * peerDependencies * @launchdarkly/node-server-sdk bumped from 9.0.6 to 9.1.1 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
Should fix #370