stencil-cli icon indicating copy to clipboard operation
stencil-cli copied to clipboard

stencil push fails with error "worker initialization failed"

Open pvaladez opened this issue 1 year ago • 18 comments

Expected behavior

stencil push works. Or an easier to see and more informative error is shown.

Actual behavior

stencil push fails with the error worker initialization failed.

Steps to reproduce behavior

Using stencil-cli version 8.4.0, as soon as you run stencil start it renames stencil.conf.js to stencil.conf.cjs. Afterward, if someone else using an older stencil-cli version like 7.5.5 then stencil push fails with a very subtle error that just says worker initialization failed.

image

I realize that this could be avoided by just making sure that everyone is using the latest version, but some of us developers are a paranoid folk who often try not to update things unless we have to. Additionally, it might not be obvious what caused this failure to happen.

Could we do something to handle this situation better? Perhaps:

  1. Leave stencil.conf.js in place, and just make a copy with the .cjs file extension
  2. Don't rename it to .cjs extension... I figure this is done because of the recent move to esm, but is it necessary?
  3. Create a field somewhere that indicates what version of stencil-cli should be compatible with the theme code. You could perhaps use this information to provide a better error in the future. a. On that note, the current version of cornerstone doesn't use the .cjs extension.

Also, I realize I'm getting a bit picky in asking for the above, but I figure it couldn't hurt to maybe consider it. Also, half the reason for writing this is for anyone else that may encounter the problem and not realize what's going on.

Environment

Stencil-cli version stencil --version: 8.4.4 / 7.5.5 Node version node -v: 18.19 NPM version npm -v: 10.2.3 OS: macOS

pvaladez avatar Oct 30 '24 01:10 pvaladez

I'm getting this error too, however my config is named config.stencil.json after it's generated.

stefanmiodrag avatar Nov 30 '24 17:11 stefanmiodrag

Having the same issue. @stefanmiodrag @pvaladez were you able to fix it and if so, how?

travisfisher-pdi avatar Dec 10 '24 15:12 travisfisher-pdi

@stefanmiodrag config.stencil.json is a different file and not related to this issue.

@travisfisher-pdi you can either update to the latest stencil-cli version, or make a copy of stencil.conf.cjs and rename it to the original filename stencil.conf.js.

pvaladez avatar Dec 11 '24 02:12 pvaladez

@travisfisher-pdi Has anybody figured this out? I am also receiving this error. I just installed the latest version of stencil cli. also my file is config.stencil.json @pvaladez

ldias2025 avatar Dec 11 '24 21:12 ldias2025

@ldias2025 @stefanmiodrag I joined the BigCommerce Developers Slack channel and did a search and everyone's feedback on the issue was to upgrade your theme version (in our case, this was the Capacity theme). I diffed the new version of the theme against our older version and brought over our customizations to the newest version (in this case, 5.0.0) and that solved the issue. I do recommend joining that Slack group if you have not done so yet. A lot of good activity there.

travisfisher-pdi avatar Dec 30 '24 14:12 travisfisher-pdi

@travisfisher-pdi thank you for the response. That is unfortunate. There is so much custom code and changes to the website I would be terrified to update it and try to see what all needs brought over.

ldias2025 avatar Jan 08 '25 16:01 ldias2025

I deleted my original complaining session to update that I was able to come up with a solution. I now realize if I would have looked at the OP a little closer, I would have resolved this much sooner. The issue was simply that stencil.conf.cjs is being renamed and/or deleted from the project at some point. Once I replace this file, everything builds as expected.

justsilencia avatar Jan 19 '25 03:01 justsilencia

I deleted my original complaining session to update that I was able to come up with a solution. I now realize if I would have looked at the OP a little closer, I would have resolved this much sooner. The issue was simply that stencil.conf.cjs is being renamed and/or deleted from the project at some point. Once I replace this file, everything builds as expected.

Are you on cornerstone theme? Where did you find the stencil.conf.cjs or stencil.conf.js file, because I cant find this anywhere. All I see is my config.stencil.json

ldias2025 avatar Jan 20 '25 13:01 ldias2025

I deleted my original complaining session to update that I was able to come up with a solution. I now realize if I would have looked at the OP a little closer, I would have resolved this much sooner. The issue was simply that stencil.conf.cjs is being renamed and/or deleted from the project at some point. Once I replace this file, everything builds as expected.

Are you on cornerstone theme? Where did you find the stencil.conf.cjs or stencil.conf.js file, because I cant find this anywhere. All I see is my config.stencil.json

@justsilencia So I looked at one of my old themes and I found the stenicl.conf.js was completely missing from my current theme , I added it back in. I am hoping this solves the problem.

ldias2025 avatar Jan 20 '25 15:01 ldias2025

@ldias2025 I am having the same issue. Glad to see there are others in my boat! Can you please advise where the stencil.conf.js should be and what it should contain? Thank you

Code-and-Spade avatar Jan 22 '25 18:01 Code-and-Spade

@ldias2025 I am having the same issue. Glad to see there are others in my boat! Can you please advise where the stencil.conf.js should be and what it should contain? Thank you

Its always nice to hear that others are experiencing the same thing and its not just me being dumb! Haha.

So the theme I was trying to push and rendered the worker initialization error did not have the stencil.conf.js file in it at all. I am not sure why. But it needs to just go in the root directory - so the same spot as other files like secrets.stencil.json, schema.json, config.json, etc. And actually when I added the stencil.conf.js ONLY and tried to do stencil start... stencil wouldnt even start. Now that I have added the stencil.conf.cjs it will load stencil AND push through. I actually have both files sitting in my root directory at the moment.

As far as what it contains I am not sure. You should be able to snag it from the original theme and just place it in the root directory of the theme you are wanting to work on and push to the site.

I hope this helps!

ldias2025 avatar Jan 22 '25 18:01 ldias2025

I just copied this file for my cornerstone theme and the stencil bundle worked!

serchrobles avatar Jan 22 '25 23:01 serchrobles

I just copied this file for my cornerstone theme and the stencil bundle worked!

Same! So happy! I hate when my Stencil messes up. Its always such a pain to figure out. Haha

ldias2025 avatar Jan 23 '25 14:01 ldias2025

@ldias2025 @serchrobles Thank you to all for your help - this did it! I can't believe it was so simple. I did get this warning, though. Can anyone weigh in on where it's coming from?

`isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration`
    at isModuleDeclaration (/Users/cas/Downloads/Cornerstone-6.16.0/node_modules/@babel/types/lib/validators/generated/index.js:2755:35)
    at PluginPass.Program (/Users/cas/Downloads/Cornerstone-6.16.0/node_modules/babel-plugin-lodash/lib/index.js:102:44)

Code-and-Spade avatar Jan 23 '25 14:01 Code-and-Spade

@ldias2025 @serchrobles Thank you to all for your help - this did it! I can't believe it was so simple. I did get this warning, though. Can anyone weigh in on where it's coming from?

`isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration`
    at isModuleDeclaration (/Users/cas/Downloads/Cornerstone-6.16.0/node_modules/@babel/types/lib/validators/generated/index.js:2755:35)
    at PluginPass.Program (/Users/cas/Downloads/Cornerstone-6.16.0/node_modules/babel-plugin-lodash/lib/index.js:102:44)

This I am not sure of. I didnt even notice I have that too until you brought it up, but everything seems to be functioning okay so I am rolling with it at the moment.

ldias2025 avatar Jan 23 '25 15:01 ldias2025

I just copied this file for my cornerstone theme and the stencil bundle worked!

Great this worked for me.

GauravI95Dev avatar Feb 10 '25 06:02 GauravI95Dev

I came across this problem this morning. Here is what happens:

  • Started with fresh copy of Cornerstone 6.15.0 theme a few months back, implemented our customizations, bundled, pushed, good to go (this fresh copy, included stencil.conf.js)
  • Today, had a make a quick change. On a "new" computer, did a "stencil download". Made my changes, did a "stencil bundle", and "working initialization failed" error.

TLDR: when you do a "stencil download" of your current theme into a "new" local directory, stencil.conf.js is NOT included. Downloaded one from the base cornerstone theme github account. dropped in folder and viola, good to go.

roodindustries avatar Mar 07 '25 19:03 roodindustries

I just copied this file for my cornerstone theme and the stencil bundle worked!

Same! So happy! I hate when my Stencil messes up. Its always such a pain to figure out. Haha

Thank you.. Its working

sudhabanerjeecc avatar Jul 07 '25 11:07 sudhabanerjeecc