Skip to content

Commit

Permalink
update node:net to enable mongodb and mysql usage (#3340)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Berchet <[email protected]>
  • Loading branch information
anonrig and vicb authored Jan 16, 2025
1 parent 703415f commit c2a6323
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/node/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,11 +769,13 @@ Socket.prototype.setNoDelay = function (

Socket.prototype.setKeepAlive = function (
this: SocketClass,
enable?: boolean,
_enable?: boolean,
_initialDelay?: number
): SocketClass {
if (!enable) return this;
throw new ERR_INVALID_ARG_VALUE('enable', enable, 'is not supported');
// Ignore this for now.
// This is used by services like mySQL.
// TODO(soon): Investigate supporting this.
return this;
};

// @ts-expect-error TS2322 Intentionally no-op
Expand Down Expand Up @@ -960,13 +962,9 @@ function initializeConnection(
let { port = 0 } = options;

if (autoSelectFamily != null) {
// We don't support this option. If the value is falsy, we can safely ignore it.
// If the value is truthy, we'll throw an error.
throw new ERR_INVALID_ARG_VALUE(
'options.autoSelectFamily',
autoSelectFamily,
'is not supported'
);
// We don't support this option.
// We shouldn't throw this because services like mongodb depends on it.
// TODO(soon): Investigate supporting this.
}

if (typeof port !== 'number' && typeof port !== 'string') {
Expand Down
4 changes: 3 additions & 1 deletion src/workerd/api/node/tests/net-nodejs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,12 @@ export const testNetConnectImmediateFinish = {
// something different than the original Node.js test
export const testNetConnectKeepAlive = {
async test() {
// Test that setKeepAlive call does not throw.
throws(() => new net.Socket({ keepAlive: true }));
const c = new net.Socket();
c.setKeepAlive(false);
throws(() => c.setKeepAlive(true));
c.setKeepAlive(true);
// throws(() => c.setKeepAlive(true));
},
};

Expand Down

0 comments on commit c2a6323

Please sign in to comment.