Skip to content

Commit e940848

Browse files
authored
Revert "Revert "Revert "NodeJS Compat: process features (#4271)"""
This reverts commit df63af9.
1 parent 9e7e656 commit e940848

30 files changed

+408
-2027
lines changed

build/wpt_test.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def wpt_test(name, wpt_directory, config, compat_date = "", compat_flags = [], a
5151
compat_date_path = compat_date_path,
5252
autogates = autogates,
5353
wpt_cacert = wpt_cacert,
54-
compat_flags = compat_flags + ["experimental", "nodejs_compat", "unsupported_process_real_platform"],
54+
compat_flags = compat_flags + ["experimental", "nodejs_compat"],
5555
)
5656

5757
data = [

src/node/events.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,5 @@
33
// https://opensource.org/licenses/Apache-2.0
44
//
55

6-
// Explicit list used to hide _initialized private export
7-
export {
8-
EventEmitter,
9-
EventEmitterAsyncResource,
10-
addAbortListener,
11-
captureRejectionSymbol,
12-
errorMonitor,
13-
getMaxListeners,
14-
usingDomains,
15-
defaultMaxListeners,
16-
setMaxListeners,
17-
listenerCount,
18-
getEventListeners,
19-
once,
20-
on,
21-
} from 'node-internal:events';
6+
export * from 'node-internal:events';
227
export { default } from 'node-internal:events';

src/node/internal/events.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
validateObject,
4343
} from 'node-internal:validators';
4444

45-
import * as process from 'node-internal:internal_process';
45+
import * as process from 'node-internal:process';
4646

4747
import { spliceOne } from 'node-internal:internal_utils';
4848

@@ -163,8 +163,6 @@ export function addAbortListener(signal: AbortSignal, listener: any) {
163163
}
164164

165165
export default EventEmitter;
166-
167-
// NOTE: all properties of event emitter must also be re-exported by the events.ts wrapper
168166
EventEmitter.on = on;
169167
EventEmitter.once = once;
170168
EventEmitter.getEventListeners = getEventListeners;
@@ -497,34 +495,26 @@ function _addListener(
497495
`added to an EventEmitter. Use ` +
498496
'emitter.setMaxListeners() to increase limit'
499497
);
500-
const w: EventEmitterError = Object.assign(
501-
new Error(
502-
'Possible EventEmitter memory leak detected. ' +
503-
`${existing.length} ${String(type)} listeners ` +
504-
`added to ${inspect(target, { depth: -1 })}. Use ` +
505-
'emitter.setMaxListeners() to increase limit'
506-
),
507-
{
508-
name: 'MaxListenersExceededWarning',
509-
emitter: target,
510-
type: type,
511-
count: existing.length,
512-
}
513-
);
514-
process.emitWarning(w);
498+
// TODO(soon): Implement process.emitWarning and inspect
499+
// // No error code for this since it is a Warning
500+
// // eslint-disable-next-line no-restricted-syntax
501+
// const w = new Error(
502+
// "Possible EventEmitter memory leak detected. " +
503+
// `${existing.length} ${String(type)} listeners ` +
504+
// `added to ${inspect(target, { depth: -1 })}. Use ` +
505+
// "emitter.setMaxListeners() to increase limit",
506+
// );
507+
// w.name = "MaxListenersExceededWarning";
508+
// w.emitter = target;
509+
// w.type = type;
510+
// w.count = existing.length;
511+
// process.emitWarning(w);
515512
}
516513
}
517514

518515
return target;
519516
}
520517

521-
interface EventEmitterError extends Error {
522-
name: string;
523-
emitter: unknown;
524-
type: string | symbol;
525-
count: number;
526-
}
527-
528518
EventEmitter.prototype.addListener = function addListener(
529519
type: string | symbol,
530520
listener: unknown
@@ -1030,8 +1020,3 @@ export function on(
10301020
iterator.return();
10311021
}
10321022
}
1033-
1034-
// Initialize the process global as an event emitter, if process executed first
1035-
if (process._initialized) process._initProcess();
1036-
1037-
export var _initialized = true;

src/node/internal/internal_errors.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,6 @@ export class ERR_EEXIST extends NodeSyscallError {
862862
}
863863
}
864864

865-
export class ERR_EPERM extends NodeSyscallError {
866-
constructor(options: { syscall: string; errno?: number }) {
867-
super('EPERM', 'Operation not permitted', options.syscall);
868-
this.errno = options.errno || 1; // EPERM
869-
}
870-
}
871-
872865
export class ERR_DIR_CLOSED extends NodeError {
873866
constructor() {
874867
super('ERR_DIR_CLOSED', 'Directory is closed');

0 commit comments

Comments
 (0)