Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Wrangler is not compatible with Node.js 17 / OpenSSL 3.0 #2108

Closed
EatonZ opened this issue Oct 19, 2021 · 11 comments 路 Fixed by #2116 or #2130
Closed

Wrangler is not compatible with Node.js 17 / OpenSSL 3.0 #2108

EatonZ opened this issue Oct 19, 2021 · 11 comments 路 Fixed by #2116 or #2130
Assignees
Labels
bug Something isn't working

Comments

@EatonZ
Copy link
Contributor

EatonZ commented Oct 19, 2021

馃悰 Bug report

Describe the bug

Node.js 17 was released today and brings OpenSSL 3.0 support. The Node.js 17 release notes mention potential cases where ERR_OSSL_EVP_UNSUPPORTED errors may occur, and that is what is happening here.

Reproduce the bug

  1. Install Node.js 17
  2. Run wrangler publish
  3. See error
node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    at C:\Users\Eaton\AppData\Local\.wrangler\wranglerjs-1.19.4\node_modules\graceful-fs\graceful-fs.js:123: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'
}

Expected behavior

No error should occur, and the publish command should succeed.

Environment and versions

Fill out the following information about your environment.

  • operating system: Windows 10 x64
  • output of wrangler -V: wrangler 1.19.4
  • output of node -v: v17.0.0
  • content of wrangler.toml: (should not be needed in this case)
@EatonZ EatonZ added the bug Something isn't working label Oct 19, 2021
@threepointone
Copy link
Contributor

threepointone commented Oct 20, 2021

This looks to be a problem with webpack 4 (which wrangler uses when type = "webpack" in wrangler.toml) We're moving away from webpack as a wrangler dependency, so this should be resolved in the next major. A temporary workaround can be to change to type = "javascript" in your wrangler.toml and setting up a custom build as described in https://developers.cloudflare.com/workers/cli-wrangler/configuration#build. Assigning this to myself, and I'll leave this open until we have a better fix in the next major release.

@threepointone threepointone self-assigned this Oct 20, 2021
@fu-sen
Copy link

fu-sen commented Oct 20, 2021

I ran into this issue at Workers Sites.

https://github.com/cloudflare/worker-sites-template/blob/master/wrangler.toml

It is exactly the same as the information so far.

@threepointone
Copy link
Contributor

Could you file an issue over there as well? We should change that template to stop using webpack.

@EatonZ
Copy link
Contributor Author

EatonZ commented Oct 20, 2021

@threepointone

A temporary workaround can be to change to type = "javascript" in your wrangler.toml and setting up a custom build as described in https://developers.cloudflare.com/workers/cli-wrangler/configuration#build.

Would you consider a new minor version in the meantime with the easier workaround described here? Just use the --openssl-legacy-provider flag.

@threepointone
Copy link
Contributor

Oh I'm glad to see there's a workaround from the node side! I'll be happy to accept a PR, I think this might be the only place for a change https://github.com/cloudflare/wrangler/blob/master/src/wranglerjs/mod.rs If no one from the community gets to this, we'll probably get it done ourselves next week.

caass pushed a commit that referenced this issue Nov 1, 2021
See #2108: Node 17 uses openssl 3 by default, which is not
compatible with webpack 4. This change adds a check to see if
the user is running node 17, and if they are, we add the appropriate
flag to the call to node (https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V17.md#openssl-30)
@caass
Copy link
Contributor

caass commented Nov 1, 2021

@EatonZ hey! I pushed some code which should fix this issue (see #2116). Could you try it out and see if it solves your problem? Just checkout the PR and run cargo install --path . :)

I'm testing the change and we'll get a review on it from someone else at cloudflare as well, but I figured you might want to give it a go yourself.

@EatonZ
Copy link
Contributor Author

EatonZ commented Nov 1, 2021

@caass Thanks! I installed Rust and ran that command, but it's not compiling successfully:

error: failed to run custom build command for `openssl-sys v0.9.70`

Caused by:
  process didn't exit successfully: `C:\Users\Eaton\Desktop\wrangler-cass-use-openssl-legacy-provider\target\release\build\openssl-sys-481b9514bf98a53c\build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  running "perl" "./Configure" "--prefix=C:\\Users\\Eaton\\Desktop\\wrangler-cass-use-openssl-legacy-provider\\target\\release\\build\\openssl-sys-d1ba01ed40f4a142\\out\\openssl-build\\install" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-legacy" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-capieng" "no-asm" "VC-WIN64A"

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', C:\Users\Eaton\.cargo\registry\src\github.com-1ecc6299db9ec823\openssl-src-300.0.2+3.0.0\src\lib.rs:490:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `wrangler v1.19.4 (C:\Users\Eaton\Desktop\wrangler-cass-use-openssl-legacy-provider)`, intermediate artifacts can be found at `C:\Users\Eaton\Desktop\wrangler-cass-use-openssl-legacy-provider\target`

Caused by:
  build failed

@caass
Copy link
Contributor

caass commented Nov 1, 2021

@EatonZ ack! i think that's an issue with the rust bindings to openssl? It looks similar to this issue, so I think you'll need to install the openssl lib? Or maybe force cargo to use default features when you install it, which i think it should anyway but you can see here where the default feature tries to use a vendored version of openssl

@EatonZ
Copy link
Contributor Author

EatonZ commented Nov 1, 2021

@caass Installing Strawberry Perl got everything working.
I can confirm your fix works and my wrangler publish commands are now working.馃憤 Thank you for the fix!

@caass
Copy link
Contributor

caass commented Nov 1, 2021

@EatonZ awesome, i'm glad! thanks for reporting the bug and providing resources on how to fix it :) very cool

caass pushed a commit that referenced this issue Nov 2, 2021
See #2108: Node 17 uses openssl 3 by default, which is not
compatible with webpack 4. This change adds a check to see if
the user is running node 17, and if they are, we add the appropriate
flag to the call to node (https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V17.md#openssl-30)
@petebacondarwin
Copy link

Be aware that if you are running webpack directly (e.g. as part of the TypeScript workers template) you will still see this error, when you run things like wrangler dev. This is because wrangler will execute: npm build, which in turn runs webpack.

The workaround in this case, rather than downgrading to node 16, is to add the node flag to the build script in package.json:

"scripts": {
    "build": "NODE_OPTIONS=--openssl-legacy-provider webpack",
    ...
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
5 participants