-
Notifications
You must be signed in to change notification settings - Fork 3
Odd bug reading from stdin #14
Description
I've got a script where I'm directly piping sourcecred score into widgets' bin/contributor-wall-svg.js here:
https://github.com/sfosc/sourcecred/blob/70dbdb6621cbaa4a2a6280a8f9d53b584d0b10f8/scripts/rebuild-site.sh#L76
In some cases (like the current sfosc/sfosc repo) this causes an EAGAIN error, both locally and on the CI build: https://drone.sfosc.robin-it.com/sfosc/sourcecred/30/1/2
Generating sfosc-sfosc-contributors.svg
Error: EAGAIN: resource temporarily unavailable, read
at Object.readSync (fs.js:498:3)
at tryReadSync (fs.js:332:20)
at readFileSync (fs.js:369:19)
at Object.<anonymous> (/drone/src/widgets/bin/contributor-wall-svg.js:26:14)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
Generating sfosc-wizard-contributors.svg
Generating sfosc-sourcecred-contributors.svg
Strangely enough it can be resolved by writing the scores to a file and using the < operator to read this file instead of | to pipe directly from the sourcecred scores output.
I can't explain why this is happening exactly yet, my suspicion is it may be related to how piping gets buffered vs reading from files. Either way the current read from stdin seems brittle.