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

[webpacker] Compilation failed with no error output #949

Closed
joshuap opened this issue Nov 16, 2022 · 9 comments
Closed

[webpacker] Compilation failed with no error output #949

joshuap opened this issue Nov 16, 2022 · 9 comments
Assignees
Labels
bug help wanted webpack @honeybadger-io/webpack

Comments

@joshuap
Copy link
Member

joshuap commented Nov 16, 2022

What are the steps to reproduce this issue?

git clone https://github.com/joshuap/honeybadger-webpacker-bug.git
cd honeybadger-webpacker-bug
bundle install
yarn install
rm -rf public/packs && rm -rf tmp/packs # make sure these directories are clean
RAILS_ENV=production HONEYBADGER_API_KEY=[project token] rails assets:precompile

What happens?

It compiles but fails to upload source maps.

What were you expecting to happen?

It should compile successfully and upload the source maps to my Honeybadger project.

Any logs, error output, etc?

You don't have net-smtp installed in your application. Please add it to your Gemfile and run bundle install
yarn install v1.22.18
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.16s.
Compiling...
Compilation failed:


What versions are you using?

Operating System: macOS Monterey 12.6
Package Name: @honeybadger-io/webpack
Package Version: 4.7.1

Front logo Front conversations

@joshuap joshuap added bug help wanted webpack @honeybadger-io/webpack labels Nov 16, 2022
@KonnorRogers
Copy link
Collaborator

KonnorRogers commented Nov 19, 2022

@joshuap I can reproduce the "compilation failed", it's also worth noting that it appears in 3 different ways across Node 14, 16, 18.

Node 14: Silent compilation failure
Node 16: Compilation fails on initial compile, running rails webpacker:compile fixes it.
Node 18: Same as Node 16, but needs an OpenSSL flag to work.

Heres what I get on Node 16.18.1 :

rm -rf public/packs && rm -rf tmp/packs && RAILS_ENV=production HONEYBADGER_API_KEY="KEY" bundle exec rails webpacker:com
pile
You don't have net-smtp installed in your application. Please add it to your Gemfile and run bundle install
Compiling...
Compilation failed:

pausing..
done pausing...
pausing..
done pausing...
Hash: 6e6af88c89b5fa371c8c
Version: webpack 4.46.0
Time: 2447ms
Built at: 11/18/2022 10:06:36 PM
                                        Asset       Size  Chunks                         Chunk Names
       js/application-cf5cff6beef247ac09a5.js   68.3 KiB       0  [emitted] [immutable]  application
    js/application-cf5cff6beef247ac09a5.js.br   15.2 KiB          [emitted]
    js/application-cf5cff6beef247ac09a5.js.gz   17.5 KiB          [emitted]
   js/application-cf5cff6beef247ac09a5.js.map    203 KiB       0  [emitted] [dev]        application
js/application-cf5cff6beef247ac09a5.js.map.br   43.3 KiB          [emitted]
js/application-cf5cff6beef247ac09a5.js.map.gz     50 KiB          [emitted]
                                manifest.json  364 bytes          [emitted]
                             manifest.json.br  128 bytes          [emitted]
                             manifest.json.gz  142 bytes          [emitted]
Entrypoint application = js/application-cf5cff6beef247ac09a5.js js/application-cf5cff6beef247ac09a5.js.map
[3] ./app/javascript/packs/application.js 507 bytes {0} [built]
[4] ./app/javascript/channels/index.js 205 bytes {0} [built]
[5] ./app/javascript/channels sync _channel\.js$ 160 bytes {0} [built]
    + 3 hidden modules

ERROR in HoneybadgerSourceMapPlugin: failed to upload js/application-cf5cff6beef247ac09a5.js.map to Honeybadger API: Invalid host defined options

However, when I just run a standard: rails assets:precompile initially it gives me the same issue you initially posted. After running rails webpacker:compile the output shows the above whenever I run rails assets:precompile I'm kinda stumped whats happening here...it feels like it may be related to the sourcemap retry uploader??

Even more bizarre heres what I get in Node 18.9.0

You don't have net-smtp installed in your application. Please add it to your Gemfile and run bundle install
yarn install v1.22.19
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.15s.
Compiling...
Compilation failed:
node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at context.callback (/Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /Users/konnorrogers/projects/oss/honeybadger-webpacker-bug/node_modules/babel-loader/lib/index.js:44:71
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.9.0

^ the above I was able to solve by doing the following:

RAILS_ENV=production HONEYBADGER_API_KEY="key" NODE_OPTIONS=--openssl-legacy-provider bundle exec rails assets:precompile

I'm not 100% what's going on here.

Also of note, the "webpacker:compile" trick doesnt work in Node 14 and produces the error seen above that you originally posted. Node 14 seems to be a no-op, most likely an unsupported module or function if I had to guess.

@subzero10
Copy link
Member

Hey @KonnorRogers,

I googled around for the Invalid host defined options error. I read here that it may be related to Typescript and ESM. We may have made changes in this area when we moved to the monorepo, so here's something you could try:

  • install a version of the @honeybadger-io/webpack package prior to v4. The latest version before the monorepo is v1.5.1
  • try the compilation command again

If this fixes it, we will have a better idea on where to debug.

Regarding the Nodejs v18 error, I also looked around and it seems that this is a known problem since node v17 and outdated dependencies. The env variable you used NODE_OPTIONS=--openssl-legacy-provider is one of the suggested workarounds. However, it seems that the safer path is to actually update npm dependencies and the issue should go away. Can you try this again after updating the dependencies with npm audit or npm update? We may have to do this for @honeybadger-io/webpack 🤔

I suggest we ignore the node v14 case for now, it may even be fixed if we deal with the above.

Let me know if I can help in any way!

@subzero10
Copy link
Member

@KonnorRogers Update:
I just reproduced the issue on my local machine.
Then I tried with @honeybadger-io/webpack@1.5.1 and it worked (with node v12), which probably means it's a bug we introduced after the monorepo migration.

@KonnorRogers
Copy link
Collaborator

KonnorRogers commented Nov 19, 2022

Alright, in further testing the "invalid API host options" is from "node-fetch-retry".

"node-fetch-retry" only gets about ~11k downloads/week and seems to be much less ubiquitous compared to:

https://www.npmjs.com/package/fetch-retry

which gets ~3million downloads/week.

I swapped the webpack project to use "fetch-retry" and it appears to work without any workarounds.

EDIT: #952 should fix this based on testing locally.

@subzero10
Copy link
Member

Awesome! I'm so glad it didn't turn out to be a bug from the monorepo transition 😌 .

@KonnorRogers
Copy link
Collaborator

@subzero10 i really have no idea where the bug is actually hiding, I commented everything out and narrowed it down to the 1 package, it have no idea what was causing it. Bizarre that it worked with the previous version. Oh well 🤷‍♂️

@subzero10
Copy link
Member

subzero10 commented Nov 21, 2022

The newer version has updated dependencies, I'm guessing there's a compatibility issue somewhere. We could dig deeper but I don't see the point now. Let's merge and test this once more with a patched version of the package.

@joshuap
Copy link
Member Author

joshuap commented Nov 22, 2022

Great work you two!

@subzero10
Copy link
Member

This should be fixed with v4.7.3 of @honeybadger-io/webpack!
I tested with node v12, v14, v16 and v18.
Note: for v18, you will have to use one of the workarounds mentioned here, for example:

NODE_OPTIONS=--openssl-legacy-provider RAILS_ENV=production HONEYBADGER_API_KEY=[project token] rails assets:precompile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted webpack @honeybadger-io/webpack
Projects
None yet
Development

No branches or pull requests

3 participants