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

Bun.serve error callback is missing the request #9015

Closed
BennyAlex opened this issue Feb 20, 2024 · 2 comments · Fixed by #9310
Closed

Bun.serve error callback is missing the request #9015

BennyAlex opened this issue Feb 20, 2024 · 2 comments · Fixed by #9310
Labels
bun.js Something to do with a Bun-specific API enhancement New feature or request

Comments

@BennyAlex
Copy link

What is the problem this feature would solve?

Accessing any information about the request that leads to the error is not possible, since there is no request parameter for the error(errorLike) callback at the moment.

Users want to show different errors based on the url or user information, or as in my case I want to set the CORS headers dynamically to the request's origin.

What is the feature you are proposing to solve the problem?

Passing the request to error() callback

What alternatives have you considered?

idk

@BennyAlex BennyAlex added the enhancement New feature or request label Feb 20, 2024
@Electroid Electroid added the bun.js Something to do with a Bun-specific API label Feb 20, 2024
@paperclover
Copy link
Member

the reason we dont have this is because the error callback might not always have the request info. if we were to implement this, i imagine it would be sort of 'best effort' and potentially null / invalid. not sure of the full details

@BennyAlex
Copy link
Author

ok but I guess in many cases it will be available and then of course we have to check if its there or not but still better than no info at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bun.js Something to do with a Bun-specific API enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants