Skip to content

Conversation

@gbkwiatt
Copy link
Contributor

@gbkwiatt gbkwiatt commented Jul 13, 2022

fixes #5088

body was always converted using response.text() which was always decoded with UTF-8 which then is breaking buffers

I understand that this only solved problem with images, this is just to illustrate the issue, and maybe someone can come up with better solution

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

this is to fix issue mentioned [here](sveltejs#5088)

body was always converted using `response.text()` which was always decoded with UTF-8 which then is breaking buffers
@changeset-bot
Copy link

changeset-bot bot commented Jul 13, 2022

🦋 Changeset detected

Latest commit: 035a2ca

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit 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

lint fix
@benmccann benmccann changed the title fix: corrupted images when using adapter-static [fix] handle binary data when prerendering Jul 14, 2022
Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

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

thank you!

as mentioned inline, I have some concerns about using Buffer.from here. i also think we need some tests before we can merge this

@gbkwiatt
Copy link
Contributor Author

gbkwiatt commented Jul 18, 2022

thank you!

as mentioned inline, I have some concerns about using Buffer.from here. i also think we need some tests before we can merge this

From myself, I can only say that your fix works fine on the project I am working on. It was a mix of content-type

null
image/svg+xml
text/html
application/xml
text/plain
image/jpeg
text/html

@gbkwiatt
Copy link
Contributor Author

@Rich-Harris I wonder if you can assist me with writing the test. I am not really familiar with repo structure, I've started writing route for the image kit/packages/kit/test/prerendering/basics/src/
to be prerendered and saved. But not sure what am I missing as it's not being saved in build folder even with crawl enabled.
The idea was to test Buffers with output file and input file, although I am not sure that's what you want to test in here since you said you have doubts with Buffer.from.

@Rich-Harris
Copy link
Member

Do you have an <img src="/path/to/route.jpg"> somewhere in the test app?

@gbkwiatt
Copy link
Contributor Author

Do you have an <img src="/path/to/route.jpg"> somewhere in the test app?

Yes that was it, I've had wrong path to image. I've pushed tests, not sure if it's sufficient but it's testing the problem I was facing.

@Rich-Harris Rich-Harris merged commit a272fd6 into sveltejs:master Jul 19, 2022
@Rich-Harris
Copy link
Member

thank you!

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.

adapter-static bug in handling binary body in standalone endpoints

4 participants