-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 streams breaking on reverted EventEmitter / Make Discord.js work #2913
Conversation
❌ @paperdave [warn] src/bun.js/events.exports.js
[warn] Code style issues found in the above file. Forgot to run Prettier?
error: "prettier" exited with code 1 (SIGHUP)
Checking formatting... To one-off fix this manually, run: bun fmt You might need to run |
src/bundler/entry_points.zig
Outdated
@@ -192,7 +192,7 @@ pub const ServerEntryPoint = struct { | |||
\\var cjs = start?.default; | |||
\\if (cjs && typeof cjs === 'function' && cjsSymbol in cjs) {{ | |||
\\ // if you module.exports = (class {{}}), don't call it | |||
\\ entryNamespace = ("prototype" in cjs) ? cjs : cjs(); | |||
\\ entryNamespace = import.meta.primordials.isCallable(cjs) ? cjs() : cjs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be in here
src/bun.js/events.exports.js
Outdated
|
||
EventEmitter.prototype[kCapture] = false; | ||
|
||
function once(emitter, type, { signal } = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't set a default argument in the function this way
people will pass null
or something truthy and then get a very strange error
src/bun.js/events.exports.js
Outdated
} | ||
EventEmitter.once = once; | ||
|
||
function on(emitter, type, { signal, close, highWatermark = Number.MAX_SAFE_INTEGER, lowWatermark = 1 } = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/bun.js/events.exports.js
Outdated
} | ||
} | ||
|
||
EventEmitter.prototype._events = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of
EventEmitter.prototype
People might mess with it at runtime
Instead, lets assign it to a local variable and use that one
const EventEmitterPrototype = EventEmitter.prototype;
❌ @paperdave 27 files with test failures on linux-x64-baseline:
|
❌ @paperdave 27 files with test failures on linux-x64:
|
❌ @paperdave 30 files with test failures on bun-darwin-x64-baseline:
|
This reverts commit a4d0a19.
Closes #2707, Closes #2077
fixes some of the things that were reverted before
in addition to this, it makes discord.js work
note for the first one, it does cause slower runtime with
and we could totally optimize this simple use case too but i did not do that.
there were two fixes to this, and i went with (2)
1 = current
2 = lazy init + old event emitter from 0.6 and prior
3 = lazy init + js event emitter + pure js streams