Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Odd bug reading from stdin #14

Open
Beanow opened this issue Aug 7, 2019 · 2 comments
Open

Odd bug reading from stdin #14

Beanow opened this issue Aug 7, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@Beanow
Copy link
Collaborator

Beanow commented Aug 7, 2019

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.

@Beanow
Copy link
Collaborator Author

Beanow commented Aug 7, 2019

The workaround:
sfosc/sourcecred@45dd1bf

Working build output:
https://drone.sfosc.robin-it.com/sfosc/sourcecred/31/1/2

@Beanow
Copy link
Collaborator Author

Beanow commented Aug 7, 2019

I was able to reproduce it more reliably using the attached scores file.
sfosc-sfosc-scores.zip

$ widgets/bin/contributor-wall-svg.js > sfosc-sfosc-contributors.svg < sfosc-sfosc-scores.json
# No problem
$ cat sfosc-sfosc-scores.json | widgets/bin/contributor-wall-svg.js > sfosc-sfosc-contributors.svg
# No problem
$ echo "$(cat sfosc-sfosc-scores.json)" | widgets/bin/contributor-wall-svg.js > sfosc-sfosc-contributors.svg
# Error: EAGAIN: resource temporarily unavailable, read

Beanow added a commit to sfosc/sourcecred that referenced this issue Aug 22, 2019
Locally generating SVGs had the same EAGAIN bug.
See sourcecred/widgets#14
Beanow added a commit to sfosc/sourcecred that referenced this issue Aug 22, 2019
Locally generating SVGs had the same EAGAIN bug.
See sourcecred/widgets#14
@Beanow Beanow added the bug Something isn't working label Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant