4.3.0 Buffer is not defined
See original GitHub issueDescribe the bug
After i compile app in production mode in vite (it uses rollup). I get the following error:
Buffer is not defined at constants.js:5
Socket.IO client version: 4.3.0
Platform:
- Device: iMac late 2015
- OS: MacOS
Additional context
I use Vercel for compilation, but i think problem is not with Vercel
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Uncaught ReferenceError: Buffer is not defined - Stack Overflow
Answering my own question. Two things helped to resolve the issue: Adding plugins section with ProviderPlugin into webpack.config.js.
Read more >cannot read properties of undefined (reading 'buffer') - You.com
It means the file is not parsed, which means the request is not correct. Change data property to include only formData , no...
Read more >Converse.js API Documentation Source: headless/dist ...
"If buffer is not empty, it contains either 12 or 18 bits. ... should not be hit in tests return index < 0...
Read more >Changelog - Cypress Documentation
This previously resulted in unusual and undefined behavior. ... We fixed a regression in 4.3.0 where the message output during errors were not...
Read more >exceljs - npm
Latest version: 4.3.0, last published: a year ago. Start using exceljs in your project ... To freeze rows only, set this to 0...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Murderlon I could indeed reproduce the issue, thanks a lot for the sample project 👍
This should be (finally!) fixed by https://github.com/socketio/engine.io-client/commit/9fcaf58d18c013c0b92fdaf27481f0383efb3658, included in
engine.io-client@6.0.3
andsocket.io-client@4.3.2
by transitivity.Please reopen if needed.
We are running into this problem when users are building Uppy with Vite: https://github.com/transloadit/uppy/issues/3265. It’s currently blocking people from going to production.
I investigated and this seems to be a dual publishing issue. If you import
socket.io-client
in ESM then everything works fine. But if you are importing it indirectly through commonjs, thensocket.io-client
shipsBuffer
to the browser, which will fail.Here is a minimal reproducible example:
vite-socketio.zip
Note: this zip includes the
node_modules
because I added afake-package
folder in there with apackage.json
andindex.js
.The
index.js
only does this:To see the error:
npm install
npm run build && npm run preview
As this is blocking our customers I’m willing to contribute to fix this but I would need some pointers to get started. As far as I know the buffer usage comes from engine.io-client.