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

don't defer closing the response writer #99

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

joeshaw
Copy link
Member

@joeshaw joeshaw commented Jan 4, 2024

Closing the response writer signifies to the Compute runtime that the
response has been successfully completed, so we shouldn't defer it in
case the handler panics.

In TinyGo, defers aren't run after panic so this wasn't executed. In
Go, defers are run. The result of this was that if a handler panicked
before sending a response, it would send an empty 200 OK response in Go
but a 500 Internal Server Error in TinyGo.

Fixes #98.

Closing the response writer signifies to the Compute runtime that the
response has been successfully completed, so we shouldn't defer it in
case the handler panics.

In TinyGo, defers aren't run after panic so this wasn't executed.  In
Go, defers are run.  The result of this was that if a handler panicked
before sending a response, it would send an empty 200 OK response in Go
but a 500 Internal Server Error in TinyGo.

Fixes #98.
@joeshaw joeshaw merged commit a015caa into main Jan 4, 2024
10 checks passed
@joeshaw joeshaw deleted the joeshaw/dont-defer-rw-close branch January 4, 2024 20:55
@Integralist
Copy link
Collaborator

@dgryski @joeshaw do we know when this will make it's way into a release?

cc @cee-dub

@joeshaw
Copy link
Member Author

joeshaw commented Jan 19, 2024

v1.2.1 was released today. https://github.com/fastly/compute-sdk-go/releases/tag/v1.2.1

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.

panic returns a 200 OK rather than 500 Internal Server Error
2 participants