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

Uncaught TypeError: t._reverse is not a function #16697

Closed
7 tasks done
pward123 opened this issue May 16, 2024 · 6 comments
Closed
7 tasks done

Uncaught TypeError: t._reverse is not a function #16697

pward123 opened this issue May 16, 2024 · 6 comments
Labels
cannot reproduce The bug cannot be reproduced pending triage

Comments

@pward123
Copy link

Describe the bug

Anytime I attempt to run a vite+react application in production mode with crypto polyfilled, the application fails to render and displays the following error in the browser js console:

Uncaught TypeError: e._reverse is not a function
    at index.e4f79b4f.js:57:13218
    at index.e4f79b4f.js:57:13616
    at index.e4f79b4f.js:1:23
    at index.e4f79b4f.js:60:733

Running the application in dev mode works just fine.

This was originally reported in #16385. However, that issue was closed and locked since it was specific to vite 2.x. This report is for the same issue in vite@5.2.11

I believe the _reverse call in question is located here

Reproduction

https://github.com/pward123/vite-issue-16385

Steps to reproduce

Follow the instructions in the readme for the reproduction repo

System Info

System:
    OS: macOS 13.6.6
    CPU: (12) x64 Apple M2 Max
    Memory: 3.95 GB / 96.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 8.6.1 - /usr/local/bin/pnpm
  Browsers:
    Brave Browser: 124.1.65.126
    Chrome: 124.0.6367.208
    Safari: 17.4.1
  npmPackages:
    @vitejs/plugin-react: ^4.2.1 => 4.2.1
    vite: ^5.2.0 => 5.2.11

Used Package Manager

npm

Logs

No response

Validations

@pward123
Copy link
Author

I've also added a minimal working rollup config on the prod-rollup branch

@sapphi-red
Copy link
Member

sapphi-red commented May 17, 2024

I followed the reproduction steps but I wasn't able to reproduce either on stackblitz or on Windows. It output Encrypted text without any errors.

@sapphi-red sapphi-red added the cannot reproduce The bug cannot be reproduced label May 17, 2024
@pward123
Copy link
Author

pward123 commented May 17, 2024

I can confirm that I'm unable to reproduce this on stackblitz. Were you using "localhost" on your Windows machine? The only thing I can think of is that the secure context you're running under is bypassing crypto-browserify.

Would you mind trying to browse to your Windows non-127.0.0.1 address?

In the mean time, I'm checking to see if updating the asn1.js transitive dependency will address this specific issue. Apparently it was updated to fix a circular dependency problem but then rolled back because it broke node v4 support in crypto-browserify.

@sapphi-red
Copy link
Member

sapphi-red commented May 17, 2024

Yeah, I was using localhost. This time I tried with other addresses, but it worked as well.

@FreeJ1nG
Copy link
Contributor

I can confirm that I'm unable to reproduce this on stackblitz. Were you using "localhost" on your Windows machine? The only thing I can think of is that the secure context you're running under is bypassing crypto-browserify.

Would you mind trying to browse to your Windows non-127.0.0.1 address?

In the mean time, I'm checking to see if updating the asn1.js transitive dependency will address this specific issue. Apparently it was updated to fix a circular dependency problem but then rolled back because it broke node v4 support in crypto-browserify.

i tried running it on my end, it works fine, here's my system spec:

  System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M2
    Memory: 116.98 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.6.2 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - /opt/homebrew/bin/npm
    pnpm: 9.0.6 - /opt/homebrew/bin/pnpm
    bun: 1.1.5 - ~/.bun/bin/bun
  Browsers:
    Chrome: 124.0.6367.208
    Safari: 17.4.1
  npmPackages:
    @vitejs/plugin-react: ^4.2.1 => 4.2.1 
    vite: ^5.2.0 => 5.2.11 

@pward123
Copy link
Author

I've changed so much in the application over the past 3 days that I couldn't even begin to work out what fixed the issue, but it's no longer happening on my non-minimal reproduction. Closing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce The bug cannot be reproduced pending triage
Projects
None yet
Development

No branches or pull requests

3 participants