Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uWebsocket with BYONM does not load native lib on Windows #25956

Open
lucacasonato opened this issue Oct 1, 2024 · 3 comments
Open

uWebsocket with BYONM does not load native lib on Windows #25956

lucacasonato opened this issue Oct 1, 2024 · 3 comments
Labels
bug Something isn't working correctly node compat node native extension related to the node-api (.node)

Comments

@lucacasonato
Copy link
Member

lucacasonato commented Oct 1, 2024

So how do i get uWebsocket insalled on deno 2.0.0-rc.8 - If at all possible
I do not have any deno experience, just want to try it because nodeJS runs into strange GC issues under high load for that project.

Running deno install provides this message

deno install
error: Error in hyper-express@6.17.2 parsing version requirement for dependency "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.48.0"

Caused by:
    Package specified a dependency outside of npm (github:uNetworking/uWebSockets.js#v20.48.0). Deno does not install these for security reasons. The npm package should be improved to have all its dependencies on npm.

    To work around this, you can use a package.json and install the dependencies via `npm install`.

But using npm install will install the build for nodeJs.
Resulting in the crash:

error: Uncaught (in promise) Error: This version of uWS.js supports only Node.js LTS versions 16, 18 and 20 on (glibc) Linux, macOS and Windows, on Tier 1 platforms (https://github.com/nodejs/node/blob/master/BUILDING.md#platform-list).

TypeError: LoadLibraryExW failed
    at file:///C:/Users/.../node_modules/uWebSockets.js/uws.js:22:9
    at Object.<anonymous> (file:///C:/Users/.../node_modules/uWebSockets.js/uws.js:24:3)
    at Object.<anonymous> (file:///C:/Users/.../node_modules/uWebSockets.js/uws.js:26:4)
    at Module._compile (node:module:748:34)
    at Object.Module._extensions..js (node:module:767:10)
    at Module.load (node:module:665:32)
    at Function.Module._load (node:module:537:12)
    at Module.require (node:module:684:19)
    at require (node:module:808:16)
    at Object.<anonymous> (file:///C:/Users/.../node_modules/hyper-express/index.js:4:21)

Originally posted by @BolverBlitz in #25648 (comment)

@lucacasonato lucacasonato added bug Something isn't working correctly node compat node native extension related to the node-api (.node) labels Oct 1, 2024
@BolverBlitz
Copy link

OS: Microsoft Windows 11 Pro
OS Version: 10.0.22631 Nicht zutreffend Build 22631
To replicate this error follow those steps:

Command: deno -A .\index.js

index.js

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);

require('dotenv').config();
require('module-alias/register');

const os = require('node:os');
const packageJSON = require('@root/package.json');
const HyperExpress = require('hyper-express');

process.package = packageJSON;

const port = process.env.BALANCER_PORT || 80;

const app = new HyperExpress.Server({
    fast_buffers: process.env.HE_FAST_BUFFER == 'false' ? false : true || false,
});

app.get('/', (req, res) => {
    res.header('Content-Type', 'text/html');
    res.send(`<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Index</title><link rel="icon" href="data:image/x-icon;,"></head><body><h1>Deno Test Branch</h1><hr><i>Test/${process.package.version}@${os.hostname}</i></body></html>`)
})

app.set_error_handler((req, res, error) => {
    console.error(error);
});

app.listen(port)
    .then((socket) => process.log.system(`Listening on port: ${port}`))
    .catch((error) => process.log.error(`Failed to start webserver on: ${port}\nError: ${error}`));

package.json

{
    "name": "deno-test",
    "version": "0.0.1",
    "description": "",
    "main": "index.js",
    "scripts": {
      "start": "node index.js",
      "update": "npx npm-check-updates -u"
    },
    "author": "",
    "license": "MIT",
    "_moduleAliases": {
      "@root": ".",
      "@src": "./src",
      "@lib": "./lib",
      "@api": "./api",
      "@middleware": "./middleware",
      "@config": "./config"
    },
    "dependencies": {
      "dotenv": "^16.4.5",
      "hyper-express": "^6.16.4",
      "module-alias": "^2.2.3"
    }
  }

Its a code sniped of a larger nodejs project i tryed porting to deno following https://docs.deno.com/runtime/fundamentals/node/

@nathanwhit
Copy link
Member

The issue causing the LoadLibraryExW error is that uWebSocket.js uses v8 APIs directly (which we don't support as it's not ABI stable).

@SebastienGllmt
Copy link

SebastienGllmt commented Nov 23, 2024

To work around this, you can use a package.json and install the dependencies via npm install.

Fixing that specific error (which is a subset of this issue) depends on #18478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat node native extension related to the node-api (.node)
Projects
None yet
Development

No branches or pull requests

4 participants