foxglove / ws-protocol

Foxglove Studio WebSocket protocol specification and libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npx @foxglove/ws-protocol-examples broken in Node 18

jtbandes opened this issue · comments

Steps To Reproduce

$ docker run -it --rm node:18 /bin/bash
root@066e73a8e175:/# npx @foxglove/ws-protocol-examples@latest sysmon
Need to install the following packages:
  @foxglove/ws-protocol-examples@0.0.8
Ok to proceed? (y) y

Expected Behavior
Examples work

Actual Behavior

(node:28) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/deps/undici/undici:11118
    Error.captureStackTrace(err, this);
          ^

TypeError: Failed to parse URL from /root/.npm/_npx/d712c844522a0ed2/node_modules/wasm-lz4/wasm-lz4.wasm
    at Object.fetch (node:internal/deps/undici/undici:11118:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:393:5)
      at URL.onParseError (node:internal/url:565:9)
      at new URL (node:internal/url:645:5)
      at new Request (node:internal/deps/undici/undici:9472:25)
      at Agent.fetch2 (node:internal/deps/undici/undici:10291:25)
      at Object.fetch (node:internal/deps/undici/undici:11116:28)
      at fetch (node:internal/process/pre_execution:216:25)
      at instantiateAsync (/root/.npm/_npx/d712c844522a0ed2/node_modules/wasm-lz4/wasm-lz4.js:9:8977)
      at createWasm (/root/.npm/_npx/d712c844522a0ed2/node_modules/wasm-lz4/wasm-lz4.js:9:9587)
      at /root/.npm/_npx/d712c844522a0ed2/node_modules/wasm-lz4/wasm-lz4.js:9:10837 {
    input: '/root/.npm/_npx/d712c844522a0ed2/node_modules/wasm-lz4/wasm-lz4.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Linear: FG-958

cruise-automation/wasm-lz4#8 has been open for over two weeks without a response. Should we create @foxglove/wasm-lz4? Obtaining ownership of the non-prefixed wasm-lz4 package is a nice goal, but as of now the package appears to be abandonware.

Fixed in #353

I am using node 18.13.0. On Ubuntu 20.04.

When i tried npx @foxglove/ws-protocol-examples@latest sysmon, it throws the following:

node:internal/deps/undici/undici:14062
    Error.captureStackTrace(err, this);
          ^

TypeError: Failed to parse URL from /home/user/.npm/_npx/3bd6f606b8f372ab/node_modules/wasm-lz4/wasm-lz4.wasm
    at Object.fetch (node:internal/deps/undici/undici:14062:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:400:5)
      at URL.onParseError (node:internal/url:565:9)
      at new URL (node:internal/url:645:5)
      at new Request (node:internal/deps/undici/undici:6914:25)
      at fetch2 (node:internal/deps/undici/undici:13228:25)
      at Object.fetch (node:internal/deps/undici/undici:14060:18)
      at fetch (node:internal/process/pre_execution:237:25)
      at instantiateAsync (/home/user/.npm/_npx/3bd6f606b8f372ab/node_modules/wasm-lz4/wasm-lz4.js:9:8977)
      at createWasm (/home/user/.npm/_npx/3bd6f606b8f372ab/node_modules/wasm-lz4/wasm-lz4.js:9:9587)
      at /home/user/.npm/_npx/3bd6f606b8f372ab/node_modules/wasm-lz4/wasm-lz4.js:9:10837 {
    input: '/home/user/.npm/_npx/3bd6f606b8f372ab/node_modules/wasm-lz4/wasm-lz4.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.13.0

I went to the _npx folder and find that:

{
  "name": "@foxglove/ws-protocol-examples",
  "version": "0.4.0",
  "description": "Foxglove WebSocket protocol examples",
  "keywords": [
    "foxglove",
    "websocket",
    "robotics",
    "ros",
    "ros2"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/foxglove/ws-protocol.git"
  },
  "author": {
    "name": "Foxglove Technologies",
    "email": "support@foxglove.dev"
  },
  "engines": {
    "node": ">= 14 <18"
  },
  "homepage": "https://foxglove.dev/",
  "module": "dist/esm/ws-protocol-examples/src/index.js",
  "main": "dist/cjs/ws-protocol-examples/src/index.js",
  "typings": "dist/esm/ws-protocol-examples/src/index.d.ts",
  "files": [
    "dist",
    "src"
  ],
  "bin": {
    "ws-protocol-examples": "dist/cjs/ws-protocol-examples/src/index.js"
  },
  "scripts": {
    "prepack": "yarn build",
    "build": "tsc -b tsconfig.json tsconfig.cjs.json",
    "lint": "eslint --report-unused-disable-directives --fix .",
    "lint:ci": "eslint --report-unused-disable-directives .",
    "test": "echo 'Nothing to test'",
    "run-example": "tsc -b ../*/tsconfig*.json && ts-node --project tsconfig.cjs.json --files src/index.ts"
  },
  "devDependencies": {
    "@foxglove/eslint-plugin": "0.20.0",
    "@foxglove/tsconfig": "1.1.0",
    "@types/debug": "^4.1.7",
    "@types/lodash": "^4.14.191",
    "@types/node": "^18.11.18",
    "@types/ws": "^8.5.4",
    "@typescript-eslint/eslint-plugin": "5.48.1",
    "@typescript-eslint/parser": "5.48.1",
    "eslint": "8.31.0",
    "eslint-config-prettier": "8.6.0",
    "eslint-plugin-es": "4.1.0",
    "eslint-plugin-filenames": "1.3.2",
    "eslint-plugin-import": "2.26.0",
    "eslint-plugin-jest": "27.2.1",
    "eslint-plugin-prettier": "4.2.1",
    "prettier": "2.8.2",
    "ts-node": "10.9.1",
    "typescript": "4.9.4"
  },
  "dependencies": {
    "@foxglove/rosmsg-serialization": "^1.5.3",
    "@foxglove/rosmsg2-serialization": "^1.1.1",
    "@foxglove/rostime": "^1.1.2",
    "@foxglove/schemas": "^0.7.3",
    "@foxglove/ws-protocol": "^0.3.2",
    "@mcap/core": "^0.3.0",
    "boxen": "^7.0.1",
    "commander": "^9.5.0",
    "debug": "^4",
    "eventemitter3": "^5.0.0",
    "protobufjs": "^7.1.2",
    "pureimage": "^0.3.15",
    "tslib": "^2",
    "wasm-lz4": "^2.0.0",
    "ws": "^8.12.0",
    "zstd-codec": "^0.1.4"
  }
}

I am not sure if this is due to using wasm-lz4 instead of @foxglove/wasm-lz4 as in package.json in main.

How do I fix this? TIA

Looks like we forgot to publish a new version of the package after making the fix. I've just published 0.5.0 now, so give it another try!

Thank you. I am happy to report that it works fine out of the box with npx @foxglove/ws-protocol-examples@latest sysmon and is currently at @foxglove/ws-protocol-examples@0.5.0.