mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
fix(ext/node): npm:mqtt compatibility (#27792)
This commit is contained in:
parent
be080784dd
commit
2511458ac1
11 changed files with 283 additions and 0 deletions
|
@ -158,6 +158,7 @@ export class TLSSocket extends net.Socket {
|
||||||
// onSocket handler of ClientRequest object.
|
// onSocket handler of ClientRequest object.
|
||||||
tlssock.emit("secure");
|
tlssock.emit("secure");
|
||||||
tlssock.removeListener("end", onConnectEnd);
|
tlssock.removeListener("end", onConnectEnd);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -414,6 +414,11 @@ class ClientRequest extends OutgoingMessage {
|
||||||
oncreate,
|
oncreate,
|
||||||
);
|
);
|
||||||
if (newSocket) {
|
if (newSocket) {
|
||||||
|
// If socket is created by createConnection option
|
||||||
|
// we apply sock-init-workaround
|
||||||
|
// This covers npm:ws and npm:mqtt
|
||||||
|
// https://github.com/denoland/deno/issues/27694
|
||||||
|
newSocket._needsSockInitWorkaround = true;
|
||||||
oncreate(null, newSocket);
|
oncreate(null, newSocket);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
BIN
tests/registry/npm/bufferutil/bufferutil-4.0.9.tgz
Normal file
BIN
tests/registry/npm/bufferutil/bufferutil-4.0.9.tgz
Normal file
Binary file not shown.
73
tests/registry/npm/bufferutil/registry.json
Normal file
73
tests/registry/npm/bufferutil/registry.json
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
{
|
||||||
|
"name": "bufferutil",
|
||||||
|
"dist-tags": {
|
||||||
|
"latest": "4.0.9"
|
||||||
|
},
|
||||||
|
"versions": {
|
||||||
|
"4.0.9": {
|
||||||
|
"name": "bufferutil",
|
||||||
|
"version": "4.0.9",
|
||||||
|
"description": "WebSocket buffer utils",
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.14.2"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"install": "node-gyp-build",
|
||||||
|
"prebuild": "prebuildify --napi --strip --target=8.11.2",
|
||||||
|
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip --target=8.11.2",
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/websockets/bufferutil.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com",
|
||||||
|
"url": "http://2x.io"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/websockets/bufferutil/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"node-gyp-build": "^4.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^11.0.1",
|
||||||
|
"node-gyp": "^11.0.0",
|
||||||
|
"prebuildify": "^6.0.0"
|
||||||
|
},
|
||||||
|
"_id": "bufferutil@4.0.9",
|
||||||
|
"gitHead": "35e2eb6a14a8d58b87bc1f9ff2ddff67e2f1fa97",
|
||||||
|
"_nodeVersion": "23.5.0",
|
||||||
|
"_npmVersion": "10.9.2",
|
||||||
|
"dist": {
|
||||||
|
"integrity": "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw==",
|
||||||
|
"shasum": "6e81739ad48a95cad45a279588e13e95e24a800a",
|
||||||
|
"tarball": "http://localhost:4260/bufferutil/bufferutil-4.0.9.tgz",
|
||||||
|
"fileCount": 11,
|
||||||
|
"unpackedSize": 371859
|
||||||
|
},
|
||||||
|
"directories": {},
|
||||||
|
"_hasShrinkwrap": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/websockets/bufferutil/issues"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com",
|
||||||
|
"url": "http://2x.io"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/websockets/bufferutil",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/websockets/bufferutil.git"
|
||||||
|
},
|
||||||
|
"description": "WebSocket buffer utils",
|
||||||
|
"readmeFilename": "README.md"
|
||||||
|
}
|
75
tests/registry/npm/utf-8-validate/registry.json
Normal file
75
tests/registry/npm/utf-8-validate/registry.json
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
{
|
||||||
|
"name": "utf-8-validate",
|
||||||
|
"dist-tags": {
|
||||||
|
"latest": "6.0.5"
|
||||||
|
},
|
||||||
|
"versions": {
|
||||||
|
"6.0.5": {
|
||||||
|
"name": "utf-8-validate",
|
||||||
|
"version": "6.0.5",
|
||||||
|
"description": "Check if a buffer contains valid UTF-8",
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.14.2"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"install": "node-gyp-build",
|
||||||
|
"prebuild": "prebuildify --napi --strip --target=8.11.2",
|
||||||
|
"prebuild-linux-musl-x64": "prebuildify-cross --image alpine --napi --strip --target=8.11.2",
|
||||||
|
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip --target=8.11.2",
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/websockets/utf-8-validate.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com",
|
||||||
|
"url": "http://2x.io"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/websockets/utf-8-validate/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"node-gyp-build": "^4.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^10.0.0",
|
||||||
|
"node-gyp": "^10.0.1",
|
||||||
|
"prebuildify": "^6.0.0",
|
||||||
|
"prebuildify-cross": "^5.0.0"
|
||||||
|
},
|
||||||
|
"_id": "utf-8-validate@6.0.5",
|
||||||
|
"gitHead": "4a9a05728641674620818c6a78b01fce38e6f222",
|
||||||
|
"_nodeVersion": "22.10.0",
|
||||||
|
"_npmVersion": "10.9.0",
|
||||||
|
"dist": {
|
||||||
|
"integrity": "sha512-EYZR+OpIXp9Y1eG1iueg8KRsY8TuT8VNgnanZ0uA3STqhHQTLwbl+WX76/9X5OY12yQubymBpaBSmMPkSTQcKA==",
|
||||||
|
"shasum": "8087d39902be2cc15bdb21a426697ff256d65aab",
|
||||||
|
"tarball": "http://localhost:4260/utf-8-validate/utf-8-validate-6.0.5.tgz",
|
||||||
|
"fileCount": 15,
|
||||||
|
"unpackedSize": 717511
|
||||||
|
},
|
||||||
|
"directories": {},
|
||||||
|
"_hasShrinkwrap": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/websockets/utf-8-validate/issues"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com",
|
||||||
|
"url": "http://2x.io"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/websockets/utf-8-validate",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/websockets/utf-8-validate.git"
|
||||||
|
},
|
||||||
|
"description": "Check if a buffer contains valid UTF-8",
|
||||||
|
"readmeFilename": "README.md"
|
||||||
|
}
|
BIN
tests/registry/npm/utf-8-validate/utf-8-validate-6.0.5.tgz
Normal file
BIN
tests/registry/npm/utf-8-validate/utf-8-validate-6.0.5.tgz
Normal file
Binary file not shown.
97
tests/registry/npm/ws/registry.json
Normal file
97
tests/registry/npm/ws/registry.json
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
{
|
||||||
|
"name": "ws",
|
||||||
|
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
|
||||||
|
"dist-tags": {
|
||||||
|
"latest": "8.18.0"
|
||||||
|
},
|
||||||
|
"versions": {
|
||||||
|
"8.18.0": {
|
||||||
|
"name": "ws",
|
||||||
|
"version": "8.18.0",
|
||||||
|
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/websockets/ws/issues"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/websockets/ws.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com",
|
||||||
|
"url": "http://2x.io"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "index.js",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"browser": "./browser.js",
|
||||||
|
"import": "./wrapper.mjs",
|
||||||
|
"require": "./index.js"
|
||||||
|
},
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"browser": "browser.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js",
|
||||||
|
"integration": "mocha --throw-deprecation test/*.integration.js",
|
||||||
|
"lint": "eslint . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"bufferutil": "^4.0.1",
|
||||||
|
"utf-8-validate": ">=5.0.2"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"bufferutil": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"utf-8-validate": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"benchmark": "^2.1.4",
|
||||||
|
"bufferutil": "^4.0.1",
|
||||||
|
"eslint": "^9.0.0",
|
||||||
|
"eslint-config-prettier": "^9.0.0",
|
||||||
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
|
"globals": "^15.0.0",
|
||||||
|
"mocha": "^8.4.0",
|
||||||
|
"nyc": "^15.0.0",
|
||||||
|
"prettier": "^3.0.0",
|
||||||
|
"utf-8-validate": "^6.0.0"
|
||||||
|
},
|
||||||
|
"_id": "ws@8.18.0",
|
||||||
|
"gitHead": "976c53c4065c49ede73bfba824caf5a6e0f290cb",
|
||||||
|
"_nodeVersion": "22.4.0",
|
||||||
|
"_npmVersion": "10.8.1",
|
||||||
|
"dist": {
|
||||||
|
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
||||||
|
"shasum": "0d7505a6eafe2b0e712d232b42279f53bc289bbc",
|
||||||
|
"tarball": "http://localhost:4260/ws/ws-8.18.0.tgz",
|
||||||
|
"fileCount": 19,
|
||||||
|
"unpackedSize": 146647
|
||||||
|
},
|
||||||
|
"directories": {},
|
||||||
|
"_hasShrinkwrap": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com",
|
||||||
|
"url": "http://2x.io"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/websockets/ws.git"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/websockets/ws",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/websockets/ws/issues"
|
||||||
|
},
|
||||||
|
"readmeFilename": "README.md"
|
||||||
|
}
|
BIN
tests/registry/npm/ws/ws-8.18.0.tgz
Normal file
BIN
tests/registry/npm/ws/ws-8.18.0.tgz
Normal file
Binary file not shown.
4
tests/specs/npm/ws_compat/__test__.jsonc
Normal file
4
tests/specs/npm/ws_compat/__test__.jsonc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"args": "run -A --cert=../../../testdata/tls/RootCA.pem main.ts",
|
||||||
|
"output": "main.out"
|
||||||
|
}
|
4
tests/specs/npm/ws_compat/main.out
Normal file
4
tests/specs/npm/ws_compat/main.out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[WILDCARD]
|
||||||
|
open on server
|
||||||
|
open on client
|
||||||
|
message on server
|
24
tests/specs/npm/ws_compat/main.ts
Normal file
24
tests/specs/npm/ws_compat/main.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import WebSocket from "npm:ws@8.18.0";
|
||||||
|
|
||||||
|
const key = Deno.readTextFileSync("../../../testdata/tls/localhost.key");
|
||||||
|
const cert = Deno.readTextFileSync("../../../testdata/tls/localhost.crt");
|
||||||
|
|
||||||
|
Deno.serve({ key, cert, port: 0, onListen }, (req) => {
|
||||||
|
const { socket, response } = Deno.upgradeWebSocket(req);
|
||||||
|
socket.addEventListener("open", () => {
|
||||||
|
console.log("open on server");
|
||||||
|
});
|
||||||
|
socket.addEventListener("message", () => {
|
||||||
|
console.log("message on server");
|
||||||
|
Deno.exit(0);
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
|
||||||
|
function onListen({ port }) {
|
||||||
|
const socket = new WebSocket(`wss://localhost:${port}`);
|
||||||
|
socket.on("open", () => {
|
||||||
|
console.log("open on client");
|
||||||
|
socket.send("hi");
|
||||||
|
});
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue