denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.26k stars 5.41k forks source link

Certain NPM module prevents whole file executing #21353

Open RihanArfan opened 1 year ago

RihanArfan commented 1 year ago

Any time I try and use Deno with npm:zeromq@6.0.0-beta.19, running my code has absolutely no output whatsoever, even breaking console.log() at the beginning of the file. I've tried running with a debugger but I get no output there too. I'm confused why I'd get no output whatsoever, not even an error.

This is the NPM package I'm trying to run, which wraps around the C library Libzmq under the hood. https://github.com/zeromq/zeromq.js

I've reported on Discord, and Marvin recommended I open an issue.

Here's a minimal repro.

// minimal-repro.ts
// deno run --unstable --allow-all --log-level=debug minimal-repro.ts

import * as zmq from "npm:zeromq@6.0.0-beta.19";

console.log("testing");
const sock = new zmq.Request(); // commenting this out will fix showing "testing" in console
Logs (commented out zeromq npm package usage

```ts import * as zmq from "npm:zeromq@6.0.0-beta.19"; console.log("testing"); // const sock = new zmq.Request(); ``` ``` $ deno run --unstable --allow-all --log-level=debug testing-client.ts DEBUG RS - deno::args::package_json:147 - package.json file found at 'D:\University\warehouse-assignment\apps\server\package.json' DEBUG RS - deno::cache::cache_db:130 - Opening cache C:\Users\Rihan\AppData\Local\deno\dep_analysis_cache_v1... DEBUG RS - deno::cache::cache_db:130 - Opening cache C:\Users\Rihan\AppData\Local\deno\node_analysis_cache_v1... DEBUG RS - deno::js:11 - Deno isolate init with snapshots. DEBUG RS - deno::worker:156 - main_module file:///D:/University/warehouse-assignment/apps/server/testing-client.ts DEBUG RS - deno::module_loader:118 - Preparing module load. DEBUG RS - deno::module_loader:139 - Creating module graph. DEBUG RS - deno::file_fetcher:550 - FileFetcher::fetch() - specifier: file:///D:/University/warehouse-assignment/apps/server/testing-client.ts DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted read access to o "D:\University\warehouse-assignment\apps\server\testing-client.ts" DEBUG RS - deno_npm::resolution::snapshot:711 - Resolved zeromq@6.0.0-beta.19 to zeromq@6.0.0-beta.19 DEBUG RS - deno_npm::resolution::graph:972 - - Resolved zeromq@6.0.0-beta.19 to zeromq@6.0.0-beta.19 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved @aminya/node-gyp-build@4.5.0-aminya.5 to @aminya/node-gyp-build@4.5.0-aminya.5 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved cross-env@^7.0.3 to cross-env@7.0.3 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved node-addon-api@^7.0.0 to node-addon-api@7.0.0 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved shelljs@^0.8.5 to shelljs@0.8.5 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved shx@^0.3.4 to shx@0.3.4 DEBUG RS - deno_npm::resolution::graph:972 - cross-env@7.0.3 - Resolved cross-spawn@^7.0.1 to cross-spawn@7.0.3 DEBUG RS - deno_npm::resolution::graph:972 - shelljs@0.8.5 - Resolved glob@^7.0.0 to glob@7.2.3 DEBUG RS - deno_npm::resolution::graph:972 - shelljs@0.8.5 - Resolved interpret@^1.0.0 to interpret@1.4.0 DEBUG RS - deno_npm::resolution::graph:972 - shelljs@0.8.5 - Resolved rechoir@^0.6.2 to rechoir@0.6.2 DEBUG RS - deno_npm::resolution::graph:972 - shx@0.3.4 - Resolved minimist@^1.2.3 to minimist@1.2.8 DEBUG RS - deno_npm::resolution::graph:972 - shx@0.3.4 - Resolved shelljs@^0.8.5 to shelljs@0.8.5 DEBUG RS - deno_npm::resolution::graph:972 - cross-spawn@7.0.3 - Resolved path-key@^3.1.0 to path-key@3.1.1 DEBUG RS - deno_npm::resolution::graph:972 - cross-spawn@7.0.3 - Resolved shebang-command@^2.0.0 to shebang-command@2.0.0 DEBUG RS - deno_npm::resolution::graph:972 - cross-spawn@7.0.3 - Resolved which@^2.0.1 to which@2.0.2 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved fs.realpath@^1.0.0 to fs.realpath@1.0.0 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved inflight@^1.0.4 to inflight@1.0.6 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved inherits@2 to inherits@2.0.4 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved minimatch@^3.1.1 to minimatch@3.1.2 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved once@^1.3.0 to once@1.4.0 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved path-is-absolute@^1.0.0 to path-is-absolute@1.0.1 DEBUG RS - deno_npm::resolution::graph:972 - rechoir@0.6.2 - Resolved resolve@^1.1.6 to resolve@1.22.8 DEBUG RS - deno_npm::resolution::graph:972 - shebang-command@2.0.0 - Resolved shebang-regex@^3.0.0 to shebang-regex@3.0.0 DEBUG RS - deno_npm::resolution::graph:972 - which@2.0.2 - Resolved isexe@^2.0.0 to isexe@2.0.0 DEBUG RS - deno_npm::resolution::graph:972 - inflight@1.0.6 - Resolved once@^1.3.0 to once@1.4.0 DEBUG RS - deno_npm::resolution::graph:972 - inflight@1.0.6 - Resolved wrappy@1 to wrappy@1.0.2 DEBUG RS - deno_npm::resolution::graph:972 - minimatch@3.1.2 - Resolved brace-expansion@^1.1.7 to brace-expansion@1.1.11 DEBUG RS - deno_npm::resolution::graph:972 - once@1.4.0 - Resolved wrappy@1 to wrappy@1.0.2 DEBUG RS - deno_npm::resolution::graph:972 - resolve@1.22.8 - Resolved is-core-module@^2.13.0 to is-core-module@2.13.1 DEBUG RS - deno_npm::resolution::graph:972 - resolve@1.22.8 - Resolved path-parse@^1.0.7 to path-parse@1.0.7 DEBUG RS - deno_npm::resolution::graph:972 - resolve@1.22.8 - Resolved supports-preserve-symlinks-flag@^1.0.0 to supports-preserve-symlinks-flag@1.0.0 DEBUG RS - deno_npm::resolution::graph:972 - brace-expansion@1.1.11 - Resolved balanced-match@^1.0.0 to balanced-match@1.0.2 DEBUG RS - deno_npm::resolution::graph:972 - brace-expansion@1.1.11 - Resolved concat-map@0.0.1 to concat-map@0.0.1 DEBUG RS - deno_npm::resolution::graph:972 - is-core-module@2.13.1 - Resolved hasown@^2.0.0 to hasown@2.0.0 DEBUG RS - deno_npm::resolution::graph:972 - hasown@2.0.0 - Resolved function-bind@^1.1.2 to function-bind@1.1.2 DEBUG RS - deno::util::fs:583 - Acquiring file lock at D:\University\warehouse-assignment\apps\server\node_modules\.deno\.deno.lock DEBUG RS - deno::util::fs:602 - Acquired file lock at D:\University\warehouse-assignment\apps\server\node_modules\.deno\.deno.lock DEBUG RS - deno::module_loader:203 - Prepared module load. testing ```

Logs (using zeromq npm package

```ts import * as zmq from "npm:zeromq@6.0.0-beta.19"; console.log("testing"); const sock = new zmq.Request(); ``` ``` $ deno --unstable run --allow-all --log-level=debug testing-client.ts DEBUG RS - deno::args::package_json:147 - package.json file found at 'D:\University\warehouse-assignment\apps\server\package.json' DEBUG RS - deno::cache::cache_db:130 - Opening cache C:\Users\Rihan\AppData\Local\deno\dep_analysis_cache_v1... DEBUG RS - deno::cache::cache_db:130 - Opening cache C:\Users\Rihan\AppData\Local\deno\node_analysis_cache_v1... DEBUG RS - deno::js:11 - Deno isolate init with snapshots. DEBUG RS - deno::worker:156 - main_module file:///D:/University/warehouse-assignment/apps/server/testing-client.ts DEBUG RS - deno::module_loader:118 - Preparing module load. DEBUG RS - deno::module_loader:139 - Creating module graph. DEBUG RS - deno::file_fetcher:550 - FileFetcher::fetch() - specifier: file:///D:/University/warehouse-assignment/apps/server/testing-client.ts DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted read access to "D:\University\warehouse-assignment\apps\server\testing-client.ts" DEBUG RS - deno_npm::resolution::snapshot:711 - Resolved zeromq@6.0.0-beta.19 to zeromq@6.0.0-beta.19 DEBUG RS - deno_npm::resolution::graph:972 - - Resolved zeromq@6.0.0-beta.19 to zeromq@6.0.0-beta.19 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved @aminya/node-gyp-build@4.5.0-aminya.5 to @aminya/node-gyp-build@4.5.0-aminya.5 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved cross-env@^7.0.3 to cross-env@7.0.3 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved node-addon-api@^7.0.0 to node-addon-api@7.0.0 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved shelljs@^0.8.5 to shelljs@0.8.5 DEBUG RS - deno_npm::resolution::graph:972 - zeromq@6.0.0-beta.19 - Resolved shx@^0.3.4 to shx@0.3.4 DEBUG RS - deno_npm::resolution::graph:972 - cross-env@7.0.3 - Resolved cross-spawn@^7.0.1 to cross-spawn@7.0.3 DEBUG RS - deno_npm::resolution::graph:972 - shelljs@0.8.5 - Resolved glob@^7.0.0 to glob@7.2.3 DEBUG RS - deno_npm::resolution::graph:972 - shelljs@0.8.5 - Resolved interpret@^1.0.0 to interpret@1.4.0 DEBUG RS - deno_npm::resolution::graph:972 - shelljs@0.8.5 - Resolved rechoir@^0.6.2 to rechoir@0.6.2 DEBUG RS - deno_npm::resolution::graph:972 - shx@0.3.4 - Resolved minimist@^1.2.3 to minimist@1.2.8 DEBUG RS - deno_npm::resolution::graph:972 - shx@0.3.4 - Resolved shelljs@^0.8.5 to shelljs@0.8.5 DEBUG RS - deno_npm::resolution::graph:972 - cross-spawn@7.0.3 - Resolved path-key@^3.1.0 to path-key@3.1.1 DEBUG RS - deno_npm::resolution::graph:972 - cross-spawn@7.0.3 - Resolved shebang-command@^2.0.0 to shebang-command@2.0.0 DEBUG RS - deno_npm::resolution::graph:972 - cross-spawn@7.0.3 - Resolved which@^2.0.1 to which@2.0.2 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved fs.realpath@^1.0.0 to fs.realpath@1.0.0 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved inflight@^1.0.4 to inflight@1.0.6 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved inherits@2 to inherits@2.0.4 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved minimatch@^3.1.1 to minimatch@3.1.2 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved once@^1.3.0 to once@1.4.0 DEBUG RS - deno_npm::resolution::graph:972 - glob@7.2.3 - Resolved path-is-absolute@^1.0.0 to path-is-absolute@1.0.1 DEBUG RS - deno_npm::resolution::graph:972 - rechoir@0.6.2 - Resolved resolve@^1.1.6 to resolve@1.22.8 DEBUG RS - deno_npm::resolution::graph:972 - shebang-command@2.0.0 - Resolved shebang-regex@^3.0.0 to shebang-regex@3.0.0 DEBUG RS - deno_npm::resolution::graph:972 - which@2.0.2 - Resolved isexe@^2.0.0 to isexe@2.0.0 DEBUG RS - deno_npm::resolution::graph:972 - inflight@1.0.6 - Resolved once@^1.3.0 to once@1.4.0 DEBUG RS - deno_npm::resolution::graph:972 - inflight@1.0.6 - Resolved wrappy@1 to wrappy@1.0.2 DEBUG RS - deno_npm::resolution::graph:972 - minimatch@3.1.2 - Resolved brace-expansion@^1.1.7 to brace-expansion@1.1.11 DEBUG RS - deno_npm::resolution::graph:972 - once@1.4.0 - Resolved wrappy@1 to wrappy@1.0.2 DEBUG RS - deno_npm::resolution::graph:972 - resolve@1.22.8 - Resolved is-core-module@^2.13.0 to is-core-module@2.13.1 DEBUG RS - deno_npm::resolution::graph:972 - resolve@1.22.8 - Resolved path-parse@^1.0.7 to path-parse@1.0.7 DEBUG RS - deno_npm::resolution::graph:972 - resolve@1.22.8 - Resolved supports-preserve-symlinks-flag@^1.0.0 to supports-preserve-symlinks-flag@1.0.0 DEBUG RS - deno_npm::resolution::graph:972 - brace-expansion@1.1.11 - Resolved balanced-match@^1.0.0 to balanced-match@1.0.2 DEBUG RS - deno_npm::resolution::graph:972 - brace-expansion@1.1.11 - Resolved concat-map@0.0.1 to concat-map@0.0.1 DEBUG RS - deno_npm::resolution::graph:972 - is-core-module@2.13.1 - Resolved hasown@^2.0.0 to hasown@2.0.0 DEBUG RS - deno_npm::resolution::graph:972 - hasown@2.0.0 - Resolved function-bind@^1.1.2 to function-bind@1.1.2 DEBUG RS - deno::util::fs:583 - Acquiring file lock at D:\University\warehouse-assignment\apps\server\node_modules\.deno\.deno.lock DEBUG RS - deno::util::fs:602 - Acquired file lock at D:\University\warehouse-assignment\apps\server\node_modules\.deno\.deno.lock DEBUG RS - deno::module_loader:203 - Prepared module load. DEBUG RS - deno::npm::managed:297 - Resolved package folder of zeromq@6.0.0-beta.19 to D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq DEBUG RS - deno::npm::managed:297 - Resolved package folder of zeromq@6.0.0-beta.19 to D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "PREBUILDS_ONLY" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "ELECTRON_RUN_AS_NODE" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "NPM_CONFIG_ARCH" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "NPM_CONFIG_PLATFORM" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "LIBC" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "ARM_VERSION" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted env access to "ZEROMQ_PREBUILD" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted read access to o "D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq\build\Release" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted read access to o "D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq\build\Debug" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted read access to o "D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq\prebuilds" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted read access to o "D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq\prebuilds\win32-x64" DEBUG RS - deno_runtime::permissions:86 - ⚠️️ Granted ffi access to "D:\University\warehouse-assignment\apps\server\node_modules\.deno\zeromq@6.0.0-beta.19\node_modules\zeromq\prebuilds\win32-x64\node.napi.glibc.node" ```

deno 1.38.3 (release, x86_64-pc-windows-msvc) v8 12.0.267.1 typescript 5.2.2

Edition Windows 11 Pro Version 23H2 Installed on ‎09/‎05/‎2023 OS build 22631.2787 Experience Windows Feature Experience Pack 1000.22681.1000.0

This is my first time with Deno and I think I'm pushing the limits of npm/node compatibility right off the bat. I wanted to use Deno for my assignment to get some experience with it as it really appeals to me over Node.js.

I'm more than happy to provide more information if needed :)

bartlomieju commented 1 year ago

This is most likely a bug in Node-API integration (seeing "Granted ffi access" in the debug log).

devsnek commented 5 months ago

As of https://github.com/denoland/deno/pull/24101 I think the root cause becomes clear:

deno: ../src/util/uvloop.h:8: uv_loop_t* zmq::UvLoop(const Napi::Env&): Assertion `status == napi_ok' failed.

This module makes use of libuv functionality and so it is not compatible with the Node-API ABI.