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

Invalid Unicode escape sequence from _buildManifest.js #17056

Closed
flybayer opened this issue Sep 13, 2020 · 7 comments · Fixed by #39965
Closed

Invalid Unicode escape sequence from _buildManifest.js #17056

flybayer opened this issue Sep 13, 2020 · 7 comments · Fixed by #39965
Assignees
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@flybayer
Copy link
Contributor

flybayer commented Sep 13, 2020

Bug report

Describe the bug

Roughly 5-10% of the time when starting the Next.js dev server in Blitz.js results in the below error in the browser immediately after first page load. This error shows in the dev error overlay and in the browser console.

SyntaxError: Invalid Unicode escape sequence        _buildManifest.js:1

Before 9.5.3, it would show as something like s is undefined.

Note: we do have concurrent mode enabled, so possibly it could have something to do with that?

To Reproduce

I'm unable to reliably reproduce, but here's how it happens:

  1. npx blitz new testapp
  2. cd testapp
  3. yarn blitz start
  4. Immediately click the localhost:3000 link as soon as it appears from the Next.js dev server
  5. Repeat steps 3 & 4 until you see the error

Expected behavior

Should not error

System information

System:
OS: macOS 10.15.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 614.28 MB / 64.00 GB
Shell: 3.1.2 - /usr/local/bin/fish
Next.js: 9.5.3

@ShikChen
Copy link

ShikChen commented Oct 16, 2020

Just hit this today. The HTTP response looks truncated with unclosed JSON. Is there any update?

@flybayer
Copy link
Contributor Author

@ShikChen did you encounter this in a blitz project or regular next.js?

@ShikChen
Copy link

It's a blitz project.

@styfle styfle modified the milestones: 11.x.x, 12.0.4 Nov 5, 2021
@timneutkens timneutkens added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Nov 16, 2021
@timneutkens timneutkens removed this from the 12.0.5 milestone Nov 17, 2021
@MisterJimson
Copy link

I just started seeing this when updating from node 16.6.2 to 16.13.0, no other changes.

@amirho1
Copy link

amirho1 commented Dec 30, 2021

@flybayer I don't think it's because of blitz.js. it happened to me in a regular project (version=12.0.4)
did you find the reason and solution also I encounter it in development I didn't test it on production

@ppedziwiatr
Copy link

ppedziwiatr commented Aug 26, 2022

So we're struggling with this in our current project.
It's just a test project that adds our library as a dependency and verifies if next.js works.

All other bundlers that we're testing (webpack 4/5, vite, rollup, parcel) work without any issue.

it builds (i.e. next build)
it runs in dev mode (i.e. next dev).

It does not run in prod mode (i.e. next start):

image

image

I've verified and \u does not come from either our library code, nor from any of the deps that are in the node_modules..

What is going on here?

EDIT: I've made some more investigation...

The original code in one of the library in the node_modules contains sth like \\n - in a "nested template" string:
${r.slice(t,n)}${`\\u${i.toString(16)}`}

The code in the bundle that next.js generates is broken for this part - i.e. it is converted into \n
image

If we bundle our library with a tool like esbuild - it handles it properly (i.e. \\n):
image

There's clearly something wrong with next.js bundling...

EDIT 2: we've also tried to use the above esbuild bundle in the next.js directly...
i.e. instead of importing our lib in next.js like this:
import {defaultCacheOptions, WarpFactory} from 'warp-contracts';

do
import {defaultCacheOptions, WarpFactory} from 'warp-contracts/web';

Our package.json has exports.web configured to point into the esbuild web bundle.

but it seems that we've hit this #31518 (comment)

This is madness :-)

EDIT 3 It seems that this double nested template string is generated by the bundlers - from sth. like plain string concatenation - so it's really hard to say which library exactly is the source of the issue (but again - it's not the library that is the issue - it's the bundler).

And as I've mentioned - the esbuild(and other bundlers) handles this properly.

We're using next.js 12.2.5, with this (I guest default?) config:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
}

module.exports = nextConfig

EDIT 4 Switching swcMinify to false fixes the issue.

huozhi added a commit that referenced this issue Sep 4, 2022
This PR updates SWC crates to swc-project/swc@f2a0eef

---


 - Closes #17056

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
atilafassina pushed a commit to atilafassina/next.js that referenced this issue Sep 5, 2022
This PR updates SWC crates to swc-project/swc@f2a0eef

---


 - Closes vercel#17056

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants