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

parseWebStream not exported in Node.js entry point #2143

Closed
Borewit opened this issue Jul 12, 2024 · 3 comments · Fixed by #2147
Closed

parseWebStream not exported in Node.js entry point #2143

Borewit opened this issue Jul 12, 2024 · 3 comments · Fixed by #2147
Assignees
Labels
bug Bug, will addressed with high priority

Comments

@Borewit
Copy link
Owner

Borewit commented Jul 12, 2024

          @Borewit Unless I'm missing something, it looks like parseWebStream is not being exported and thus cannot be used: https://github.com/Borewit/music-metadata/blob/v9.0.0/lib/index.ts#L11.

Furthermore, on use of this code:

const response = await fetch(`https://my/mp3/file`);
const metadata = await parseWebStream(response.body!, response.headers.get('content-type')!, {
  skipPostHeaders: true,
  includeChapters: true,
  skipCovers: true
});

I get this error:

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'stream' must be a byte stream. Received ReadableStream { locked: false, state: 'readable', supportsBYOB: false }
    at new NodeError (node:internal/errors:405:5)
    at setupReadableStreamBYOBReader (node:internal/webstreams/readablestream:2155:11)
    at new ReadableStreamBYOBReader (node:internal/webstreams/readablestream:916:5)
    at ReadableStream.getReader (node:internal/webstreams/readablestream:352:12)
    at new WebStreamReader (file:///home/pcbowers/projects/hono/node_modules/.pnpm/[email protected]/node_modules/peek-readable/lib/WebStreamReader.js:12:30)
    at Module.fromWebStream (file:///home/pcbowers/projects/hono/node_modules/.pnpm/[email protected]/node_modules/strtok3/lib/core.js:25:36)
    at Module.parseWebStream (file:///home/pcbowers/projects/hono/node_modules/.pnpm/[email protected]/node_modules/music-metadata/lib/core.js:29:39)
    at Array.eval (/home/pcbowers/projects/hono/src/index.ts:12:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getRequestListener.overrideGlobalObjects (file:///home/pcbowers/projects/hono/node_modules/.pnpm/@[email protected][email protected]/node_modules/@hono/vite-dev-server/dist/dev-server.js:69:32) {
  code: 'ERR_INVALID_ARG_VALUE'

I wish I knew more about it or else I would have debugged further! Leaving this here instead of on a new issue since I think fixing this would solve "avoid parsing entire file"

Originally posted by @pcbowers in #2135 (comment)

@Borewit
Copy link
Owner Author

Borewit commented Jul 12, 2024

@pcbowers The ReadableStream must be indeed be a byte stream. Why fetch does not provide you one, I do not know.

To see a working Web stream in action, try: https://audio-tag-analyzer.netlify.app/

@pcbowers
Copy link

Hmm, don't we still need to export parseWebStream to make it usable?

https://github.com/Borewit/music-metadata/blob/v9.0.0/lib/index.ts#L11

@Borewit Borewit changed the title Issue parsing Web Stream parseWebStream not exported in Node.js entry point Jul 15, 2024
@Borewit
Copy link
Owner Author

Borewit commented Jul 15, 2024

Hmm, don't we still need to export parseWebStream to make it usable?

https://github.com/Borewit/music-metadata/blob/v9.0.0/lib/index.ts#L11

I would say it would, good catch!

@Borewit Borewit added the bug Bug, will addressed with high priority label Jul 15, 2024
Borewit added a commit that referenced this issue Jul 15, 2024
@Borewit Borewit self-assigned this Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, will addressed with high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants