tatethurston / TwirpScript

A protobuf RPC framework for JavaScript and TypeScript
MIT License
142 stars 13 forks source link

fs.readSync intermittent error #191

Closed andrewbeckman closed 2 years ago

andrewbeckman commented 2 years ago

When we run yarn twirpscript, we are intermittently getting the following error:

[TwirpScript] Using configuration file at '/home/brian/rundoo/web/.twirp.json'.
[TwirpScript] Protobuf Compiler Error: 

node:fs:747
  handleErrorFromBinding(ctx);
  ^

Error: EAGAIN: resource temporarily unavailable, read
    at Object.readSync (node:fs:747:3)
    at tryReadSync (node:fs:447:20)
    at readFileSync (node:fs:493:19)
    at file:///home/brian/rundoo/web/node_modules/twirpscript/compiler.js:4:15
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
    at async loadESM (node:internal/process/esm_loader:83:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12) {
  errno: -11,
  syscall: 'read',
  code: 'EAGAIN'
}

I unfortunately don't have repeatable steps to reproduce, but here's our .twirp.json:

{
  "root": "../rd/rpc",
  "dest": "src/rpc_clients",
  "language": "typescript"
}
tatethurston commented 2 years ago

Thanks @andrewbeckman. Did you notice this after updating to a particular version or has this happened intermittently for awhile?

andrewbeckman commented 2 years ago

Thanks @andrewbeckman. Did you notice this after updating to a particular version or has this happened intermittently for awhile?

We have noticed it across versions for a while. We just updated to the latest version and are still seeing it.

tatethurston commented 2 years ago

Thanks. Could you let me know the node version and OS you’re seeing this on?

andrewbeckman commented 2 years ago

Thanks. Could you let me know the node version and OS you’re seeing this on?

So on the team we have mostly Macs running macOS Monterey and node LTS (version 16.x). We have one Linux user running node 18.6.0. We all experience it intermittently, but the Linux user experiences it with greater frequency.

tatethurston commented 2 years ago

Awesome, thanks. I'll look into this.

tatethurston commented 2 years ago

I haven't been able to reproduce this yet, but doing some research I found this stackoverflow thread that references the same EAGIN issue: https://stackoverflow.com/questions/30441025/read-all-text-from-stdin-to-a-string

I'm going to publish an update replacing process.stdin.fd with 0. The two should be equivalent, but at least on Node v11 some users reported this same problem.

tatethurston commented 2 years ago

This is published in v0.0.62. LMK if this resolves the issue @andrewbeckman, and if not, I'll do some deeper digging into node.