Skip to content

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Feb 8, 2024

Should fix #370

@shortcut-integration
Copy link

expect(serverResult.headers['sample-header']).toEqual('Some header value');
});

it('rejection is handled for response even if not awaited', async () => {
Copy link
Member Author

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;
Copy link
Member Author

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.

@kinyoklion kinyoklion marked this pull request as ready for review February 8, 2024 18:10
@kinyoklion kinyoklion merged commit dd6d0e7 into main Feb 8, 2024
@kinyoklion kinyoklion deleted the rlamb/sc-232944/response-rejection branch February 8, 2024 21:25
@github-actions github-actions bot mentioned this pull request Feb 8, 2024
kinyoklion added a commit that referenced this pull request Feb 8, 2024
🤖 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>
kinyoklion added a commit that referenced this pull request Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LaunchDarkly node-server-sdk is crashing node process due to unhandled promise

3 participants