Skip to content

Conversation

@adventure-yunfei
Copy link
Contributor

Uint8Array defined an unwritable from property, which causes overwritting operation after changing Buffer.__proto__ fails and break script execution.

e.g. failing to assign ".from" property in Chrome:
image

When use buffer with webpack, everything after Buffer.from = ... just gone.

And e.g. failing to require buffer in node@4
image

We should move "Buffer.from" assignment forward to avoid this error.

Note that this may not be reproducible on all browser. In some browsers (or node@6) Uint8Array doesn't have 'from', or defines a writable 'from' property.

@feross
Copy link
Owner

feross commented Dec 2, 2016

What version of Chrome are you using? I've never seen this error.

@feross
Copy link
Owner

feross commented Dec 2, 2016

I suppose this can't do any harm, so why not?

@feross feross merged commit 88941ed into feross:master Dec 2, 2016
@feross
Copy link
Owner

feross commented Dec 2, 2016

Released as 5.0.2

@adventure-yunfei
Copy link
Contributor Author

@feross I've printed out chrome version (which is 50.0.2661.102), and node version (which is 4.4.4). On these platforms, Object.getOwnPropertyDescriptor(Uint8Array.__proto__, 'from') will get a non-writable descriptor.

(And I've also tested latest [email protected] and [email protected] which shows it's writable instead.)

@feross
Copy link
Owner

feross commented Jan 23, 2017

@adventure-yunfei Sounds good. Thanks for testing!

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.

2 participants