fix: end the FileStreamWriter for the installer file #47
Loading…
Reference in a new issue
No description provided.
Delete branch "colemickens/fix-stream-close"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
We have a failure on a repo where
Error: spawn ETXTBSY
was observed after #46 was merged.Taking a closer look, we should be
close()
-ing the WritableStream, and thenend()
ing the FileStreamWriter.ref:
WritableStream
:close()
: https://nodejs.org/api/webstreams.html#writablestreamcloseFileStreamWriter
:end()
: https://nodejs.org/api/stream.html#writableendchunk-encoding-callbackChecklist
Update:
pipeTo()
closes the WritableStream itself (ref: https://2ality.com/2022/06/web-streams-nodejs.html ctrl-f "writablestream is closed")Random:
@ -438,2 +435,2 @@
const fileStreamWeb = stream.Writable.toWeb(fileStream);
await response.body.pipeTo(fileStreamWeb);
const handle = await open(
tempfile,
Referring to https://nodejs.org/api/fs.html#filehandlecreatewritestreamoptions, I'm not sure this syncs the file. I wonder if we also need to call...
https://nodejs.org/api/fs.html#filehandlesync
@ -438,2 +435,2 @@
const fileStreamWeb = stream.Writable.toWeb(fileStream);
await response.body.pipeTo(fileStreamWeb);
const handle = await open(
tempfile,
Ah, yes, and the nice solution I found is to call
fs.createWriteStream
with options{ flush: true}
, but of course that's only in node 21.@ -438,2 +435,2 @@
const fileStreamWeb = stream.Writable.toWeb(fileStream);
await response.body.pipeTo(fileStreamWeb);
const handle = await open(
tempfile,
what interesting is that the code I changed wasn't calling sync explicitly, and was just waiting for the finished signal. (which I'd assume is similar to awaiting the
pipeTo
)I'm going to going to really wack this with a big hammer, open the file so I get a filehandle, make sure it gets fsync'd explicitly and see how this fares.
@ -438,2 +435,2 @@
const fileStreamWeb = stream.Writable.toWeb(fileStream);
await response.body.pipeTo(fileStreamWeb);
const handle = await open(
tempfile,
further musing: there's a "synchronous append" mode (
as
) for opening, but not an equivalent forw
? But there isrs+
:Unfortunately this results in an error when running the checks:
I realize now we don't actually note that we use the same style as https://github.com/actions/javascript-action so you need to run
npm run all
before every commit. :( We need to add this to the readme.#48 should fix the lack of a check!
I agree we need #48 (and that I had a diff in
dist
), but the error you got was from not re-runningnpm install
, it definitely in thepackage-lock.json
at the most recent commit.(edit: also, note the CI was green, so it was able to build, also pointing to it just being a lack of
npm install
run locally).I rebased this on #48, hopefully we can merge it first if we want it, otherwise I'll rebase this again.
now I'm hitting: https://github.com/nodejs/node/issues/48466