1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(node/inspector): Session constructor should not throw (#25041)

There is no constructor code when creating an inspector `Session`
instance in Node. Also get rid of some symbols which should've been
private properties. This PR doesn't yet add any new implementations
though as these are mostly cosmetic changes.
This commit is contained in:
Marvin Hagemeister 2024-08-14 15:34:24 +02:00 committed by GitHub
parent 130a2592f1
commit c765d9ad2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 20 deletions

View file

@ -1,26 +1,18 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent and Node contributors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license.
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
import { EventEmitter } from "node:events"; import { EventEmitter } from "node:events";
import { notImplemented } from "ext:deno_node/_utils.ts"; import { notImplemented } from "ext:deno_node/_utils.ts";
import { primordials } from "ext:core/mod.js";
const connectionSymbol = Symbol("connectionProperty"); const {
const messageCallbacksSymbol = Symbol("messageCallbacks"); SafeMap,
const nextIdSymbol = Symbol("nextId"); } = primordials;
const onMessageSymbol = Symbol("onMessage");
class Session extends EventEmitter { class Session extends EventEmitter {
[connectionSymbol]: null; #connection = null;
[nextIdSymbol]: number; #nextId = 1;
[messageCallbacksSymbol]: Map<string, (e: Error) => void>; #messageCallbacks = new SafeMap();
constructor() {
super();
notImplemented("inspector.Session.prototype.constructor");
}
/** Connects the session to the inspector back-end. */ /** Connects the session to the inspector back-end. */
connect() { connect() {
@ -33,10 +25,6 @@ class Session extends EventEmitter {
notImplemented("inspector.Session.prototype.connectToMainThread"); notImplemented("inspector.Session.prototype.connectToMainThread");
} }
[onMessageSymbol](_message: string) {
notImplemented("inspector.Session.prototype[Symbol('onMessage')]");
}
/** Posts a message to the inspector back-end. */ /** Posts a message to the inspector back-end. */
post( post(
_method: string, _method: string,

View file

@ -1,7 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import inspector from "node:inspector"; import inspector, { Session } from "node:inspector";
import { assertEquals } from "@std/assert/equals"; import { assertEquals } from "@std/assert/equals";
Deno.test("[node/inspector] - importing inspector works", () => { Deno.test("[node/inspector] - importing inspector works", () => {
assertEquals(typeof inspector.open, "function"); assertEquals(typeof inspector.open, "function");
}); });
Deno.test("[node/inspector] - Session constructor should not throw", () => {
new Session();
});