question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

zlib error using `@jbrowse/react-linear-genome-view` with vite

See original GitHub issue

I made a small test example of @jbrowse/react-linear-genome-vew in an app build with vite. Basically I copied over the app code from here. I had to use the solution described here to polyfill stream (for @gmod/gff) and zlib (for @gmod/cram) (I left out all the other polyfills in that example).

The app builds, but encounters an error trying to display a CRAM track:

serverSideRenderedBlock.ts:135 TypeError: Cannot read properties of undefined (reading '-5')
    at Zlib2._binding.onerror (node-modules-polyfills:zlib:357:26)
    at Zlib._error (binding.js:264:8)
    at Zlib._write (binding.js:222:10)
    at Zlib.writeSync (binding.js:171:15)
    at Gunzip.Zlib2._processChunk (node-modules-polyfills:zlib:510:31)
    at zlibBufferSync (node-modules-polyfills:zlib:229:17)
    at Object.gunzipSync (node-modules-polyfills:zlib:173:10)
    at CramFile._uncompress (file.js:247:27)
    at CramFile.readBlock (file.js:298:12)
    at async CramSlice.getBlocks (index.js:208:19)

image

This also could be a bug in the zlib polyfill, but I’m not really sure.

Code for a repro is here: https://codesandbox.io/s/ylt4t with the app running here: https://ylt4t.sse.codesandbox.io/.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
cmdcolincommented, Feb 18, 2022

we could possibly also improve docs related to vite in our readme’s…will consider what can be done

1reaction
cmdcolincommented, Feb 16, 2022

a new version of @gmod/cram is published (v1.6.1) that switches to pako for browser bundles, so does not require a zlib polyfill

a similar thing was also added to @gmod/bbi which also used zlib and was published as v1.0.32 so it is possible you can use the code without a zlib polyfill now, but I haven’t confirmed that

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: global is not defined | React ...
Current behaviour Getting an Uncaught ReferenceError while using ... zlib error using @jbrowse/react-linear-genome-view with vite ...
Read more >
@jbrowse/react-linear-genome-view - npm
Start using @jbrowse/react-linear-genome-view in your project by running `npm i @jbrowse/react-linear-genome-view`.
Read more >
jbrowse/react-linear-genome-view examples - CodeSandbox
Learn how to use @jbrowse/react-linear-genome-view by viewing and forking example apps that make use of @jbrowse/react-linear-genome-view on CodeSandbox.
Read more >
Vite.js build with lib option not loading react app - Stack Overflow
json and tsconfig.json with build with lib configuration, it worked properly using with normal vite build but fails does not work on build...
Read more >
Embedded components - JBrowse
JBrowse React Linear Genome View ​ ; vite, demo · source code (download), for vite, we use rollup to polyfill some node polyfills...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found