Closed dferber90 closed 1 year ago
This was identified to be a problem of SWC. It can be reproduced by typing "\x000"
into https://swc.rs/playground, which mistakenly produces \00
.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime)
Link to the code that reproduces this issue
https://github.com/uncurated-tests/debug-statsig
To Reproduce
Describe the Bug
I’m running into what seems to be an encoding difference between middleware and Edge API Routes
Specifically I’m importing a module which contains Buffer.from("someString") and this value of someString is encoded differently in .next/server/pages/api/exp.js and .next/server/middleware.js. The actual value can be seen here.
Original value in third-party package is a binary encoded in a buffer:
Value in .next/server/middleware.js (same as above)
Value in .next/server/pages/api/exp.js (wrong encoding)
Note the
\x
escaped values like\xf3\0\0\x01\x01\x01\x02\x03\x03\x04\x04\b\x03\x10\x05 \x03@\x05\x80\x06\x01\x03\x01\x02
in the last one which you see when you scroll right. They do not appear in the first two.This screenshot makes the encoding difference obvious
Expected Behavior
Edge API Routes should produce the same output for the Buffer as Middleware.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response