FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Write to temp outfile until success, fixes #899 by natevw · Pull Request #1673 · browserify/browserify · GitHub

Write to temp outfile until success, fixes #899 - #1673

Merged
1 commit merged into
browserify:masterfrom
natevw:patch-1
Feb 14, 2017
Merged

1 commit merged into
browserify:masterfrom
natevw:patch-1

Conversation

natevw commented Jan 6, 2017

Copy link
Copy Markdown
Contributor

Write browserify command output to a temporary file, overwriting the target file atomically upon success (and simply cleaning up the tempfile on error).

This has two benefits:

  • user won't be left with an empty file if compilation fails (which can break toolchains that rely on destination files/timestamps to indicate build status, Make or django-pipeline for just two examples) i.e. fixes Browserify should not create empty output files on error #899
  • output file can never end up in a half-written state during even a successful compilation

Write browserify command output to a temporary file, overwriting the target file atomically upon success (and simply cleaning up the tempfile on error).

This has two benefits:

* user won't be left with an empty file if compilation fails (which can break toolchains that rely on destination files/timestamps to indicate build status, Make or django-pipeline for just two examples)
* output file can never end up in a half-written state during even a successful compilation

ghost commented Jan 18, 2017

Copy link
Copy Markdown

This patch looks good to me. Do you think this change should be a major or minor version bump?

natevw commented Jan 18, 2017

Copy link
Copy Markdown
Contributor Author

@substack Hmmm, that's a good question. Given that this behavior wasn't documented [afaik?] and wasn't usually useful [imo], I'd call it a bug fix. But technically it does change the external behavior of the CLI tool, and therefore could conceivably break a build process that relies on the "empty file" behavior.

natevw commented Jan 27, 2017

Copy link
Copy Markdown
Contributor Author

@feross @substack Any chance this could still get snuck into the major bump to 14?

feross commented Jan 27, 2017
edited
Loading

Copy link
Copy Markdown
Member

I'm fine considering this a patch or minor version, and doing a release. But would like confirmation from @substack that he agrees.

ghost commented Jan 27, 2017

Copy link
Copy Markdown

a minor version seems ok

feross commented Jan 27, 2017

Copy link
Copy Markdown
Member

I actually don't have the time to do a release right now, sorry. Another maintainer want to take this?

ghost merged commit ea6c299 into browserify:master Feb 14, 2017

ghost commented Feb 14, 2017

Copy link
Copy Markdown

Thanks everyone. This feature has landed in 14.1.0.

ljharb commented Feb 14, 2017
edited
Loading

Copy link
Copy Markdown
Member

The module-deps upgrade is a breaking change; node 0.8 doesn't have setImmediate. Please revert ASAP in the 14.x line.

ghost commented Feb 14, 2017

Copy link
Copy Markdown

This was fixed in 14.1.1 by using process.nextTick(). Thanks for catching this @ljarb.

ljharb commented Feb 14, 2017

Copy link
Copy Markdown
Member

woot, thanks! 🎉

benwiley4000 commented Jul 13, 2017
edited
Loading

Copy link
Copy Markdown

Looks like #1746 is related to this one (bundle write to temp file fails, but only if package.json has a "browser" field, and "main" is set equal to the source file). Any ideas why?

natevw commented Sep 22, 2017

Copy link
Copy Markdown
Contributor Author

@benwiley4000 I do not know why this would cause your issue, though I can't claim to fully understand your setup either. (Hopefully there's no internal code that tries to open the [eventual] output file for reading before it is finished being generated?)

Copy link
Copy Markdown

@natevw yeah, I'm not sure why either - I just know that when I was testing, I was able to reliably pinpoint the bug's origin with a before/after.

If you're curious about a repro, try running npm run build on this repo: https://github.com/benwiley4000/gif-frames

It should work find as-is, but if you change the name of the bundled field in package.json to browser it should fail (keep in mind that when browserify consumes a module it looks for the browser field so this could be related somehow).

This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Browserify should not create empty output files on error

4 participants


Back | FazBrowse Home | New Git URL