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

[fix] adapter-netlify: handle undefined body #2682

Merged
merged 1 commit into from
Oct 25, 2021
Merged

[fix] adapter-netlify: handle undefined body #2682

merged 1 commit into from
Oct 25, 2021

Conversation

benmccann
Copy link
Member

Swap the condition so that when body is undefined, null, etc. we don't try to pass it into Buffer.from. Also, the old check wasn't quite correct in checking if the type was a string because you really should do typeof myVar === 'string' || myVar instanceof String

@Xenonym @Egnus do you want to check if this fix works for you?

@benmccann benmccann added the bug Something isn't working label Oct 25, 2021
@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2021

🦋 Changeset detected

Latest commit: c538704

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-netlify Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@Xenonym Xenonym left a comment

Choose a reason for hiding this comment

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

@benmccann works for me! Thanks for fixing this 😓

However, I note that the Output of EndpointHandler should be JSONString | Uint8Array, which means that it should never be undefined / null in the first place right?

Copy link

@Egnus Egnus left a comment

Choose a reason for hiding this comment

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

Worked like a charm after enforcing these changes in the render function (via build)

@benmccann
Copy link
Member Author

However, I note that the Output of EndpointHandler should be JSONString | Uint8Array, which means that it should never be undefined / null in the first place right?

body is optional though:

@benmccann benmccann merged commit e276386 into master Oct 25, 2021
@benmccann benmccann deleted the netlify branch October 25, 2021 16:18
@Xenonym
Copy link
Contributor

Xenonym commented Oct 25, 2021

body is optional though:

@benmccann ah I missed that! Thanks for clarifying 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants