question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not wait for process to finish

See original GitHub issue

We have a process that writes a value to a file which is then required by the actual build process like this:

git describe --tags HEAD >.app-version || date --rfc-3339=seconds >.app-version

Then, the “version file” generated as above is require()d in the application source.

It turns out this plugin does not wait for the command to finish before passing control back to webpack, because today we got an error during the JS build:

ModuleNotFoundError: Module not found: Error: Cannot resolve 'file' or 'directory' ../.app-version in /builds/xxx/src

Here is a more minimal demonstration:

                new WebpackShellPlugin({
                        onBuildStart: [
                                'sleep 60; touch .myfile'
                        ],
                        safe: true
                })

Then, if you run your build as usual, it will actually finish before the file has been created. This prevents you from require()ing files generated as such in your webpack project.

I see 2 solutions:

  • Use the callback interface provided by Webpack plugin API, or
  • Use execSync instead of exec

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:19
  • Comments:6

github_iconTop GitHub Comments

6reactions
Feiyang1commented, Nov 18, 2017

I made a fork that allows you to block until the scripts finish execution. please check it out: https://www.npmjs.com/package/webpack-synchronizable-shell-plugin

3reactions
danielyaa5commented, Aug 20, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to NOT wait for a process to complete in batch script?
Is there a way (or a switch) for it NOT to wait and just spawn the process and continue?
Read more >
task that does not wait for process to exit #66840 - GitHub
I wanted to make a task which will build a project and open resulting pdf-file in pdf viewer, for example "tasks": [ {...
Read more >
cron job does not wait end of process - Super User
When I execute my script manually from the cli, it work fine waiting the end of each instruction before go to the next...
Read more >
Process.WaitForExit Method (System.Diagnostics)
WaitForExit(Int32 ) makes the current thread wait until the associated process terminates. It should be called after all other methods are called on...
Read more >
Unchecking "Wait for Process to Complete?" in a Process Call ...
Hi @HeeKeat Foo (Customer), Unchecking "wait for process to complete" instructs the calling process to immediately continue executing other paths in the calling ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found