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

fix arraybuffer error in Node.js > 18 #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vectorrent
Copy link

I tried to use TokenMonster in Node 18, and it failed with this error:

/home/crow/Repos/ode/src/tokenizers/tokenmonster.cjs:205
        const dataView = new DataView(buffer)
                         ^

TypeError: First argument to DataView constructor must be an ArrayBuffer
    at new DataView (<anonymous>)
    at TokenMonster.load (/home/crow/Repos/ode/src/tokenizers/tokenmonster.cjs:205:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async TokenMonsterTokenizer.init (file:///home/crow/Repos/ode/src/tokenizers.js:144:9)
    at async OmnipotentDeterministicEngine.preInit (file:///home/crow/Repos/ode/src/model.v0.js:53:13)
    at async OmnipotentDeterministicEngine.init (file:///home/crow/Repos/ode/src/model.v0.js:59:9)
    at async orchestrate (file:///home/crow/Repos/ode/cli.js:73:9)
    at async file:///home/crow/Repos/ode/cli.js:130:5

Node.js v18.20.3

The fix was fairly simple; if we cast the URL buffer to an ArrayBuffer, this works just fine.

Thanks for building an awesome tokenizer! I'm very excited to get started here.

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

Successfully merging this pull request may close these issues.

None yet

1 participant