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

TypeError with webpack 4.x and create-react-app #264

Open
bgins opened this issue Jul 16, 2021 · 6 comments
Open

TypeError with webpack 4.x and create-react-app #264

bgins opened this issue Jul 16, 2021 · 6 comments

Comments

@bgins
Copy link
Member

bgins commented Jul 16, 2021

Problem

Using webnative 0.26 with the react-scripts local dev server and build results in TypeErrors.

Impact

It is difficult to use webnative 0.26 with an app generated by create-react-app.

Detail

When running react-scripts start, the local dev server fails with an error in the browser:

cra-wn-26

Running react-scripts build succeeds, but the built app does not load and fails with a Uncaught TypeError: can't convert BigInt to number error.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https:/fission-suite/react-todomvc
  2. Upgrade it to webnative 0.26.0
  3. Test the local dev server with npm start
  4. Test the build with npm run build
@matheus23
Copy link
Contributor

matheus23 commented Jul 20, 2021

Can you try it with current main (now that this PR is merged with a similar webpack 4.x issue)?

@bgins
Copy link
Member Author

bgins commented Jul 20, 2021

Tried this out on main at 01360d9 and I'm seeing the same errors.

To make sure I am testing this correctly, these were my steps:

  1. Pull the latest webnative on main
  2. nix-shell, yarn install, yarn build to build webnative
  3. In my project, npm install ../webnative (that's where webnative is relatively)
  4. Run my project as above in the original bug report

I think that's the right way to test this, but just want thorough to make sure I didn't overlook something!

@matheus23
Copy link
Contributor

I figured out the source of the problem: The stacktrace in the image somehow shows the wrong code for line 36. It's actually a line containing Buffer.concat(...). That function won't work if its arguments aren't buffers, which for some reason is the case with your build (but not with lots of other builds???).

I'll just remove the last remaining usage of Buffer from webnative, I think it makes sense to switch to Uint8Arrays and the uint8arrays library anyway (because that's what supported in both nodejs and the browser natively).

@bgins
Copy link
Member Author

bgins commented Jul 22, 2021

Nice, good find! Yeah, that makes sense to switch over to Uint8Array.

@matheus23
Copy link
Contributor

Thanks!
Unfortunately, we can't make the switch right now without breaking our tests. jest doesn't have TextEncoder support, which is need to convert Uint8Arrays to strings. jestjs/jest#9983
Not sure how to proceed. There's a PR for this issue, but it's older than a year with no end in sight.
We also can't easily switch to testEnvironment: node, because that setting is managed by jest-puppeteer.

@matheus23
Copy link
Contributor

More closely related discussion on this: achingbrain/uint8arrays#17

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

No branches or pull requests

2 participants