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

Creating a TransformStream accesses Object.prototype.type #46355

Closed
KhafraDev opened this issue Jan 26, 2023 · 1 comment · Fixed by #46389
Closed

Creating a TransformStream accesses Object.prototype.type #46355

KhafraDev opened this issue Jan 26, 2023 · 1 comment · Fixed by #46389

Comments

@KhafraDev
Copy link
Member

KhafraDev commented Jan 26, 2023

Version

v19.5.0

Platform

No response

Subsystem

webstreams

What steps will reproduce the bug?

Object.defineProperty(Object.prototype, 'type', {
  get () {
    throw new Error('accessed type')
  }
})

const transformStream = new TransformStream({
  transform (chunk, controller) {
    controller.enqueue(chunk)
  },
  flush (controller) {
    controller.terminate()
  }
})

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

It shouldn't access Object.prototype.type.

What do you see instead?

file:///C:/Users/khafra/Documents/test.mjs:3
    throw new Error('accessed type')
          ^

Error: accessed type
    at Object.get (file:///C:/Users/khafra/Documents/test.mjs:3:11)
    at new WritableStream (node:internal/webstreams/writablestream:157:22)
    at initializeTransformStream (node:internal/webstreams/transformstream:360:20)
    at new TransformStream (node:internal/webstreams/transformstream:154:5)
    at file:///C:/Users/khafra/Documents/test.mjs:7:25
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

Additional information

This can be fixed by adding type: undefined to the WritableStream and ReadableStream options that TransformStream creates. Or making it a null prototype (via __proto__: null) should also probably work.

@KhafraDev
Copy link
Member Author

There's a WPT for this at https://raw.githubusercontent.com/web-platform-tests/wpt/master/fetch/api/basic/stream-safe-creation.any.js although it relies on fetch things. There might be one for webstreams only but I haven't looked.

nodejs-github-bot pushed a commit that referenced this issue Feb 2, 2023
Fixes: #46355
PR-URL: #46389
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
MylesBorins pushed a commit that referenced this issue Feb 18, 2023
Fixes: #46355
PR-URL: #46389
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this issue Apr 11, 2023
Fixes: #46355
PR-URL: #46389
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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.

1 participant