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

Buffer is undefined in the linear-view #72

Closed
AcaDemIQ opened this issue Oct 13, 2023 · 3 comments
Closed

Buffer is undefined in the linear-view #72

AcaDemIQ opened this issue Oct 13, 2023 · 3 comments

Comments

@AcaDemIQ
Copy link

Hello,
I use JBrowse2 embedded version of the Linear View (v2.7.0)
And I've got this strange error:

ReferenceError: Buffer is not defined
    _fetchFromIndexEntry indexedFasta.ts:216
    getResiduesByName indexedFasta.ts:183
    getSequence indexedFasta.ts:193
    fill IndexedFastaAdapter.js:15
    fill AbortablePromiseCache.js:48
    get AbortablePromiseCache.js:135
    getFeatures IndexedFastaAdapter.js:73
    RxJS 22
    getFeatures FeatureRendererType.js:111
    render FeatureRendererType.js:133
    execute CoreRender.js:41
    call MainThreadRpcDriver.js:30

изображение

Can you help me with this problem?

Best regards, Aleksey.

@cmdcolin
Copy link
Collaborator

Hi there,
Generally a lot of our modules will require 'polyfilling' the Buffer module.

You can for example

npm install buffer

Then in your react code, maybe at app startup, write

import {Buffer} from 'buffer'
window.Buffer= buffer

There are also more 'automatic' ways to do this within the bundler system with e.g. the webpack NodePolyfillPlugin, but the above way is the easiest approach.

Example of NodePolyfillPlugin here https://github.com/GMOD/jbrowse-react-linear-genome-view-cra5-demo/blob/main/craco.config.js#L10-L12

Example of the window.Buffer=Buffer approach here https://github.com/GMOD/jbrowse-react-linear-genome-view-vite-demo/blob/main/src/main.tsx#L5-L7

Just curious, was this issue something new that happened when using v2.7.0?

@cmdcolin
Copy link
Collaborator

cmdcolin commented Oct 13, 2023

random side note: We may in the future try to make it so that we don't need the Buffer polyfill but it may take awhile as it is part of many of our data parsing packages

@AcaDemIQ
Copy link
Author

Okey, I get it, close this ticket
Thanks a lot.

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