nucypher/taco-web

[Docs] WASM-pack template project doesn't seem to work with node v18

Closed this issue · 3 comments

The Get Started section in TAC docs have a link to a template of a webpack wrapper to use WASM in a Javascript project.

This process is mostly automated by the wrapper generated by wasm-pack.

In my experience, if you are using node v18, this example will not run. And it will work if you use node v14. No mention about this in our docs or in wasm-pack docs.

This can be an obstacle for someone trying to learn how to integrate nucypher-ts WASM code in a project.

Would it be possible for you to reproduce this issue in a separate code example (repository)?

Would it be possible for you to reproduce this issue in a separate code example (repository)?

I'm not sure how to reproduce it in a separate repo since I'm just following the instructions here: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/using-your-library.html

But I can paste here the terminal's log:

When trying to follow the steps with node v18.17.0:

$ nvm install lts/hydrogen
Downloading and installing node v18.17.0...
Downloading https://nodejs.org/dist/v18.17.0/node-v18.17.0-darwin-arm64.tar.xz...
############################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v18.17.0 (npm v9.6.7)


$ cd my-new-wasm-app/


$ npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated fsevents@1.2.9: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
npm WARN deprecated ini@1.3.5: Please update to ini >=1.3.6 to avoid a prototype pollution issue
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-url@0.4.0: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated source-map-resolve@0.5.2: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

added 587 packages, and audited 588 packages in 10s

18 packages are looking for funding
  run `npm fund` for details

38 vulnerabilities (1 low, 3 moderate, 28 high, 6 critical)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.


$ npm start

> create-wasm-app@0.1.0 start
> webpack-dev-server

(node:56298) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
ℹ 「wds」: Project is running at http://localhost:8081/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/manumonti/wip/my-new-wasm-app
node:internal/crypto/hash:69
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/manumonti/wip/my-new-wasm-app/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/manumonti/wip/my-new-wasm-app/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/manumonti/wip/my-new-wasm-app/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/manumonti/wip/my-new-wasm-app/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/manumonti/wip/my-new-wasm-app/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/manumonti/wip/my-new-wasm-app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/manumonti/wip/my-new-wasm-app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/Users/manumonti/wip/my-new-wasm-app/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Users/manumonti/wip/my-new-wasm-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
    at /Users/manumonti/wip/my-new-wasm-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
    at /Users/manumonti/wip/my-new-wasm-app/node_modules/graceful-fs/graceful-fs.js:78:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.17.0

When following the steps with node v14.17.0:

$ nvm install lts/fermium
AP=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_ARM64' '-DV8_EMBEDDER_STRING="-node.88"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DENABLE_MINOR_MC' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_CONCURRENT_MARKING' '-DV8_ARRAY_BUFFER_EXTENSION' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DDISABLE_UNTRUSTED_CODE_MITIGATIONS' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_SNAPSHOT_COMPRESSION' '-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_STATIC_IMPLEMENTATION=1' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/v8 -I../deps/v8/include -I/Users/manumonti/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj/gen/inspector-generated-output-root -I../deps/v8/third_party/inspector_protocol -I/Users/manumonti/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj/gen/torque-output-root -I/Users/manumonti/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj/gen/generate-bytecode-output-root -I../deps/icu-small/source/i18n -I../deps/icu-small/source/common -I../deps/v8/third_party/zlib -I../deps/v8/third_party/zlib/google  -O3 -gdwarf-2 -fstrict-aliasing -mmacosx-version-min=10.13 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/manumonti/.nvm/.cache/src/node-v14.21.3/files/out/Release/.deps//Users/manumonti/.nvm/.cache/src/node-v14.21.3/files/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/objects/property.o.d.raw   -c

[...]

installing /Users/manumonti/.nvm/versions/node/v14.21.3/include/node/openssl/archs/BSD-x86_64/no-asm/include/openssl/opensslconf.h
installing /Users/manumonti/.nvm/versions/node/v14.21.3/include/node/zconf.h
installing /Users/manumonti/.nvm/versions/node/v14.21.3/include/node/zlib.h
Now using node v14.21.3 (npm v6.14.18)

$ npm init wasm-app my-new-wasm-app
npx: installed 1 in 1.274s
🦀 Rust + 🕸 Wasm = ❤



$ cd my-new-wasm-app/



$ npm install

> fsevents@1.2.9 install /Users/manumonti/wip/my-new-wasm-app/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
npnode-pre-gyp WARN Tried to download(403): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v83-darwin-arm64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.9 and node@14.21.3 (node-v83 ABI, unknown) (falling back to source compile with node-gyp)
m   SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:6:
In file included from ../node_modules/nan/nan.h:2818:
../node_modules/nan/nan_typedarray_contents.h:34:43: warning: 'GetContents' is deprecated: Use GetBackingStore. See http://crbug.com/v8/9908. [-Wdeprecated-declarations]
      data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
                                          ^
/Users/manumonti/Library/Caches/node-gyp/14.21.3/include/node/v8.h:5272:3: note: 'GetContents' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.")
  ^
/Users/manumonti/Library/Caches/node-gyp/14.21.3/include/node/v8config.h:402:39: note: expanded from macro 'V8_DEPRECATE_SOON'
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
                                      ^
1 warning generated.
  SOLINK_MODULE(target) Release/fse.node
  COPY /Users/manumonti/wip/my-new-wasm-app/node_modules/fsevents/lib/binding/Release/node-v83-darwin-arm64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp
added 655 packages from 379 contributors and audited 655 packages in 5.826s

18 packages are looking for funding
  run `npm fund` for details

found 132 vulnerabilities (3 low, 37 moderate, 74 high, 18 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
  


$ npm start

> create-wasm-app@0.1.0 start /Users/manumonti/wip/my-new-wasm-app
> webpack-dev-server

ℹ 「wds」: Project is running at http://localhost:8081/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/manumonti/wip/my-new-wasm-app
ℹ 「wdm」: Hash: aa14e1ff7e4be3389129
Version: webpack 4.43.0
Time: 180ms
Built at: 07/25/2023 11:12:49 AM
                           Asset       Size  Chunks                         Chunk Names
                  0.bootstrap.js    3.4 KiB       0  [emitted]
8e8fa9289c240ac706a1.module.wasm  872 bytes       0  [emitted] [immutable]
                    bootstrap.js    369 KiB    main  [emitted]              main
                      index.html  297 bytes          [emitted]
Entrypoint main = bootstrap.js
[0] multi (webpack)-dev-server/client?http://localhost:8081 ./bootstrap.js 40 bytes {main} [built]
[./bootstrap.js] 279 bytes {main} [built]
[./index.js] 56 bytes {0} [built]
[./node_modules/ansi-html/index.js] 4.16 KiB {main} [built]
[./node_modules/ansi-regex/index.js] 135 bytes {main} [built]
[./node_modules/hello-wasm-pack/hello_wasm_pack.js] 698 bytes {0} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8081] (webpack)-dev-server/client?http://localhost:8081 4.29 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.51 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.53 KiB {main} [built]
[./node_modules/webpack-dev-server/client/utils/createSocketUrl.js] (webpack)-dev-server/client/utils/createSocketUrl.js 2.91 KiB {main} [built]
[./node_modules/webpack-dev-server/client/utils/log.js] (webpack)-dev-server/client/utils/log.js 964 bytes {main} [built]
[./node_modules/webpack-dev-server/client/utils/reloadApp.js] (webpack)-dev-server/client/utils/reloadApp.js 1.59 KiB {main} [built]
[./node_modules/webpack-dev-server/client/utils/sendMessage.js] (webpack)-dev-server/client/utils/sendMessage.js 402 bytes {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
    + 21 hidden modules
ℹ 「wdm」: Compiled successfully.

Closed by #299