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

"src.subarray is not a function" in blitBuffer #20762

Closed
tmcw opened this issue Oct 2, 2023 · 2 comments · Fixed by #20769
Closed

"src.subarray is not a function" in blitBuffer #20762

tmcw opened this issue Oct 2, 2023 · 2 comments · Fixed by #20769
Assignees

Comments

@tmcw
Copy link

tmcw commented Oct 2, 2023

My previous bug report in #20616 around blitBuffer was fixed, but this surfaced a bug a few lines below the old one (both bugs were surfaced with this testcase that tries to use web-push).

The error is src.subarray is not a function, and can be replicated with the same code sample as in the previous bug report:

➜  val.town git:(v3) ✗ deno
Deno 1.37.1
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import { Buffer } from "node:buffer"
undefined
> Buffer.from('ZmRzYWZkYWZkc2E', 'base64url')
Uncaught TypeError: src.subarray is not a function
    at blitBuffer (ext:deno_node/internal/buffer.mjs:1779:15)
    at Uint8Array.base64urlWrite (ext:deno_node/internal/buffer.mjs:691:10)
    at Object.write (ext:deno_node/internal/buffer.mjs:2195:11)
    at Uint8Array.write (ext:deno_node/internal/buffer.mjs:794:14)
    at fromString (ext:deno_node/internal/buffer.mjs:214:22)
    at _from (ext:deno_node/internal/buffer.mjs:119:12)
    at Function.from (ext:deno_node/internal/buffer.mjs:157:10)
    at <anonymous>:2:8

As far as I can tell, the blitBuffer method is usually passed an Array as its first argment:

utf8ToBytes(string, this.length - offset),

But the subarray method only exists on TypedArray instances. It seems like this file - buffer.mjs - has neither tests nor types. Maybe this could get some test coverage?

@bartlomieju
Copy link
Member

CC @aapoalas could you take a look?

@aapoalas aapoalas self-assigned this Oct 3, 2023
@aapoalas aapoalas linked a pull request Oct 3, 2023 that will close this issue
@aapoalas
Copy link
Collaborator

aapoalas commented Oct 3, 2023

I opened a fix PR. This file is tested by the Node tests but apparently either some of them are disabled or Node's test coverage isn't too great?

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 a pull request may close this issue.

3 participants