Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Error: EOF: end of file, read" on Windows #11314

Closed
ot-jim-elphick opened this issue Nov 5, 2020 · 17 comments
Closed

Getting "Error: EOF: end of file, read" on Windows #11314

ot-jim-elphick opened this issue Nov 5, 2020 · 17 comments
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort jsii This issue originates in jsii, or this feature must be implemented in jsii. p1

Comments

@ot-jim-elphick
Copy link

ot-jim-elphick commented Nov 5, 2020

description of the bug:

returns JSII error on empty stack. May be related to #5187.

stack trace references SyncStdio.readLine (myfolder\jsii_embedded\jsii\jsii-runtime.js:13278:33)
Comment in code at 'throw e':

// HACK: node may set O_NONBLOCK on it's STDIN depending on what kind of input it is made
// of (see https://github.com/nodejs/help/issues/2663).
. . .
// "tracked" at https://github.com/aws/aws-cdk/issues/5187

Reproduction Steps

(using powershell) This follows example from https://docs.aws.amazon.com/cdk/latest/guide/ecs_example.html
mkdir myfolder
cd myfolder
cdk init --language python
.env\Scripts\activate.ps1
python -m pip install -r requirements.txt
cdk synth

What did you expect to happen?

return an empty stack with no error

What actually happened?

(.env) p$[myfolder]> cdk synth                                                                                                                      D:\d:\myfolder\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13295
                    throw e;
                    ^

Error: EOF: end of file, read
    at Object.readSync (fs.js:592:3)
    at SyncStdio.readLine (D:\d:\myfolder\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13278:33)
    at InputOutput.read (D:\d:\myfolder\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13203:34)
    at KernelHost.run (D:\d:\myfolder\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13021:32)
    at Immediate.<anonymous> (D:\d:\myfolder\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13029:37)
    at processImmediate (internal/timers.js:461:21) {
  errno: -4095,
  syscall: 'read',
  code: 'EOF'
}
Resources:
  CDKMetadata:
    Type: AWS::CDK::Metadata
    Properties:
      Modules: aws-cdk=1.69.0,@aws-cdk/cloud-assembly-schema=1.69.0,@aws-cdk/core=1.69.0,@aws-cdk/cx-api=1.69.0,@aws-cdk/region-info=1.69.0,jsii-runtime=Python/3.7.4
    Metadata:
      aws:cdk:path: myfolder/CDKMetadata/Default
    Condition: CDKMetadataAvailable

Environment

  • CLI Version : aws-cli/2.0.61 Python/3.7.7 Windows/10 exe/AMD64
  • Framework Version: 1.69.0 (build 2b474b9)
  • Node.js Version: v14.15.0
  • OS : Windows 10
  • Language (Version): python 3.7.4

Other

Error is persistent and easily reproduced on my machine.
I re-installed/upgraded aws cli to 2.0.61
I re-installed node.js
I re-installed cdk
Note: As noted in the section above, this 'hello world' level error still creates a stack. However, when more code is added, more jsii errors occur and the stack fails. Also, code that errors on my machine runs normally on other machines.

@ot-jim-elphick ot-jim-elphick added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 5, 2020
@SomayaB SomayaB changed the title jsii Returns JSII error on empty stack Nov 5, 2020
@SomayaB SomayaB added the jsii This issue originates in jsii, or this feature must be implemented in jsii. label Nov 5, 2020
@RomainMuller RomainMuller added the p1 label Nov 6, 2020
@RomainMuller
Copy link
Contributor

I am unable to reproduce this problem on macOS/UNIX. Have to prepare a windows environment to attempt reproduction there; which might take a little while.

@RomainMuller
Copy link
Contributor

Good news - I was able to reproduce it now (on Windows)! I'll try to figure out what's happening here...

@RomainMuller
Copy link
Contributor

Alright - so the EOF error is thrown by fs.readSync on Windows when EOF. This does not appear to happen on *nixes and I'm also unable to directly reproduce this behavior (when I try to, the fs.readSync call properly returns 0 when EOF is reached, as documented).

This isn't quite the first oddity we have faced that mostly affects Windows users (as you've noted the hack we already have in place for EAGAIN)... I'm going to try a little harder to identify a reproduction and hopefully be able to file a bug report to node...

Interestingly, this error happens as the app has correctly finished (the Python process then closes the node process' STDIN to signal it's done and the node process should clean up after itself and exit - and this is what triggers the crash). This actually you'd be able to "work around" this by running your app.py and then running cdk with -a cdk.out until we have found a way to conclusively fix this problem.

If we're not finding a better solution fast enough, we'll have to actually identify this EOF error and actually handle it was if fs.readSync had returned 0....

@RomainMuller
Copy link
Contributor

Alright I have been able to come up with a simple repro, which actually demonstrates the reason I could not "easily" reproduce previously is because of the difference in nature of the process.stdin when node is started directly as opposed to when Python creates a subprocess with piped in- and output.

@RomainMuller
Copy link
Contributor

Filed a bug to NodeJS (nodejs/node#35997).

@ot-jim-elphick
Copy link
Author

ot-jim-elphick commented Nov 6, 2020

Merci! Thank you for your help!

This tells me to focus on node.js. I will try using some previous version of node.js as a remedy. If that works, I will post the nodejs version here.

@RomainMuller RomainMuller changed the title Returns JSII error on empty stack Getting "Error: EOF: end of file, read" on Windows Nov 9, 2020
@RomainMuller RomainMuller removed the needs-triage This issue or PR still needs to be triaged. label Nov 9, 2020
@RomainMuller
Copy link
Contributor

I seem unable to reproduce this issue on GitHub Actions where I'd run node 14.14.0. I'm uncertain whether this is due to peculiarities of the GitHub Actions environment, or if node 14.14.0 is exempt from the faulty behavior.

@ot-jim-elphick
Copy link
Author

@RomainMuller Workaround: replace jsii 1.14.x distro in site-packages with 1.12 or 1.13 distro. After swap, errors stop.

TL;DR
I was able to swap out the 1.14.1 distro in the site-packages for the jsii 1.12 distro. Same code that consistently threw the error reported above, now runs with no errors. This behavior corresponds to the the reports from other devs (where I got the jsii 1.12 distro) that they had no issues with the code.

Rolling back node.js or cdk to earlier versions had no effect because pip install - r requirements.txt always installed the 1.14.x distro.

Longer term fix: move dev platform from Windows to linux.

@kenchoong
Copy link

kenchoong commented Nov 12, 2020

still see this in cdk version 1.73.0 and python 3.8

@enrico-usai
Copy link

Same issue Python 3.9.0 and CDK 1.74.0 (build e86602f)

(.venv) C:\hello-cdk>cdk ls
C:\hello-cdk\.venv\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13295
                    throw e;
                    ^

Error: EOF: end of file, read
    at Object.readSync (fs.js:592:3)
    at SyncStdio.readLine (C:\hello-cdk\.venv\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13278:33)
    at InputOutput.read (C:\hello-cdk\.venv\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13203:34)
    at KernelHost.run (C:\hello-cdk\.venv\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13021:32)
    at Immediate.<anonymous> (C:\hello-cdk\.venv\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13029:37)
    at processImmediate (internal/timers.js:461:21) {
  errno: -4095,
  syscall: 'read',
  code: 'EOF'
}
hello-cdk

(.venv) C:\hello-cdk>python --version
Python 3.9.0

(.venv) C:\hello-cdk>cdk --version
1.74.0 (build e86602f)

@khomesh696
Copy link

@RomainMuller Workaround: replace jsii 1.14.x distro in site-packages with 1.12 or 1.13 distro. After swap, errors stop.

TL;DR
I was able to swap out the 1.14.1 distro in the site-packages for the jsii 1.12 distro. Same code that consistently threw the error reported above, now runs with no errors. This behavior corresponds to the the reports from other devs (where I got the jsii 1.12 distro) that they had no issues with the code.

Rolling back node.js or cdk to earlier versions had no effect because pip install - r requirements.txt always installed the 1.14.x distro.

Longer term fix: move dev platform from Windows to linux.

how should i install this jsii1.12 version in windows

@nulli2nd
Copy link

RE: "how should I install this jsii1.12 version in windows"

The 2nd answer in the stackoverflow question below expands on the 2 workarounds given.

https://stackoverflow.com/questions/64694569/

@enrico-usai
Copy link

@nulli2nd should be enough to execute: pip install jsii==1.13 in your virtual environment.

@RomainMuller
Copy link
Contributor

@ot-jim-elphick thanks for the deep dive, and sorry for not having gotten back there earlier... I'm going to investigate this further to try and understand what changed between 1.13.0 and 1.14.0 that can explain this behavior change.

@RomainMuller RomainMuller added the effort/medium Medium work item – several days of effort label Dec 3, 2020
@RomainMuller
Copy link
Contributor

Is this still happening with 1.15.0?

@enrico-usai
Copy link

I confirm that the issue is solved. Thanks!

$ cdk --version
1.74.0 (build e86602f)

$ pip list | grep jsii
jsii                               1.15.0

$ cdk ls
reading
hello-cdk

@RomainMuller RomainMuller removed their assignment Jun 21, 2021
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort jsii This issue originates in jsii, or this feature must be implemented in jsii. p1
Projects
None yet
Development

No branches or pull requests

7 participants