Closed papb closed 4 years ago
@ryan-snyder Thanks for the info! Maybe this is something with cypress then. I will open an issue there. Thanks.
https://nodejs.org/api/stream.html#stream_event_end
By default, stream.end() is called on the destination Writable stream when the source Readable stream emits 'end', so that the destination is no longer writable. To disable this default behavior, the end option can be passed as false, causing the destination stream to remain open:
I had the following in my code:
testProcess.stdout.pipe(process.stdout);
basically, one stream pipes to another one which can't handle END event. Hope this helps, for me it worked via adding options object:
testProcess.stdout.pipe(process.stdout, { end: false });
@alexk0ch Hello, thanks for this, looks promising, but where exactly should I add your code above? Thanks!
yes, if cypress is piping streams there was a breaking change as far as I understand in node 10. We've started to get this error after migration to node 10. Code above is from our custom build tool.
@alexk0ch Hello again, sorry to bother, I still don't understand where exactly should I place that line of code you posted, can you clarify? Thanks!
@alexk0ch I also dont understand where exactly should I place that line of code you posted, can you clarify? Thanks!
Note: I tried with Node 8.16, but the error continues.
node v10.15.3, 8.12.0
"cypress": "^3.2.0", "husky": "^2.2.0"
can't reproduce issue from @papb's steps
@alexk0ch interesting. Perhaps the new version of husky fixed this? Can you test with older versions?
@alexk0ch @papb I'm still getting this exact issue with
husky@2.3.0
cypress@3.2.0
@dmauldin I haven't had the time to test it yet, so thanks for your comment :grin: Maybe this is an OS issue? I was using windows, what did you use? And @alexk0ch, what did you use? Thanks!
@dmauldin I haven't had the time to test it yet, so thanks for your comment 😁 Maybe this is an OS issue? I was using windows, what did you use? And @alexk0ch, what did you use? Thanks!
osx, latest
Windows, as well. Node 10.15.3. Powershell.
Also tried downgrading husky to 2.2.0 and upgrading cypress to 3.3.1 (separately), neither of which made any difference.
Wouldn't be the first time Windows gave me grief trying to do something that works in a non-windows environment. ;)
So, from the cypress issue listed above, it looks like their fix is to run in bash on windows (ie: no actual fix in cypress). It at least looks like it's a Windows issue, since every single person that says it doesn't work is doing it on Windows and everybody that can't repro is not on Windows.
Maybe it's time to close this issue and just refer people to the cypress issue?
@dmauldin I can't test right now, can you test with Git Bash for example and see if it works? Thanks a lot!
@ryan-snyder Just to make sure I understand, the cypress issue didn't solve your problem (yet), right? Did you try renanperalta's comment?
(again, I'm asking because I didn't have time to test anything yet)
@papb that fix is specifically for gitlab on Windows, which I'm not doing. I'm just using husky locally on Windows. I tried using git-bash, but it's the same failure. Using WSL bash may work, but that's a long stretch as then you have to install a metric tonne of libraries to support cypress, as even when running headless, it still needs all the X libs, gtk, etc.
I'm going to spend about another hour on this today and then move on, since the cypress team knows about it, but just aren't visibly doing anything about it. I'm hoping I may be able to find a simple change to the existing libs to get around the problem.
@dmauldin thanks again for all the info. Hopefully I'll have some time soon to take another look on this...
@jennifer-shehane sorry to bother but can you give your opinion on this? Do you think this is on cypress or on husky? Thanks!
Hi, any update/fix on this issue? I am using:
"husky": {
"version": "2.7.0",
}
"cypress": {
"version": "3.4.1",
}
Facing the same exact issue.
We believe this is an issue with Cypress on Windows and not with Husky. We have an open PR that fixes this in https://github.com/cypress-io/cypress/pull/5045 (fixes the direction of the STDIN pipe)
@bahmutov Nice!!
Not related to husky , but im using koa in strapi to pipe pdf content to the response, i faced same , i used the solution mentioned by @alexk0ch ,and its working, thanks!
if (fs.existsSync(getUrlName)) { let createstream = fs.createReadStream(getUrlName); ctx.response.set("content-type", "application/pdf"); ctx.response.set("Content-Disposition", "attachment; filename=${fetchedfileName}.pdf"); ctx.body= ctx.req.pipe(createstream,{ end: false }); return await next(); }
Summary of the bug
My pre-commit hook calls
npm test
. The test itself succeeds but then husky fails with the following error:My test uses cypress. I am opening the issue here on
husky
and not oncypress
becausenpm test
works fine when called directly, but the pre-commit hook fails.Fully detalied steps to reproduce the bug
mkdir test && cd test
git init
.gitignore
file fornode_modules
npm init -y
npm i --save-dev husky cypress
npx cypress open
cypress/integration/sample_spec.js
with the following content:rm -r cypress/integration/examples
package.json
and change thetest
script to be"cypress run"
npm test
- Just to observe that the test command works perfectlypackage.json
:git commit -m "Initial commit"
. The cypress test will run and succeed, but then, right after:Versions
husky: 1.3.1 node: 10.15.0 npm: 6.4.1 cypress: 3.1.5 OS: Windows_NT x64 6.1.7601