Skip to content
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

feat: Add async support to Bun.serve onError #8233

Merged
merged 10 commits into from
Jan 19, 2024

Conversation

LukasKastern
Copy link
Contributor

What does this PR do?

Handle promise returned from onError.
Fixes: #8217

  • Code changes

How did you verify your code works?

I wrote automated tests

) void {
var vm = ctx.server.vm;

switch (promise.status(vm.global.vm())) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy of what RequestContext.onResponse is doing. I'm not sure if this is the correct way of handling the promise.

{
ctx.flags.is_error_promise_pending = true;
ctx.pending_promises_for_abort += 1;
promise_js.then(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added new callbacks for the error resolve/reject but realized that using onResolve / onError is working fine due to the deduplication check in runErrorHandlerWithStatusCodeDontCheckResponded.

@TiBianMod
Copy link

Many many thanks again @LukasKastern

Vielen Dank 😄

Copy link
Member

@cirospaciari cirospaciari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thank you

@cirospaciari cirospaciari merged commit 751ff68 into oven-sh:main Jan 19, 2024
26 of 31 checks passed
ryoppippi pushed a commit to ryoppippi/bun that referenced this pull request Feb 1, 2024
* WIP

* Support not immediately fullfilled promises

* Typo

* Add tests

* Fix test

* Rename test

* Remove file

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.

Bun.serve throw Error log on async error
4 participants