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

Error: spawn Unknown system error -8 after node-tunnel 4.0.0 release #39

Closed
vrockaibrx opened this issue Apr 14, 2023 · 10 comments
Closed

Comments

@vrockaibrx
Copy link

Our pipeline stopped working properly few our ago - cca at the same time as the 4.0.0 release of the tunnel.

The error is:

Current version of Node Tunnel:  3.0.14
It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using: 
npm update @lambdatest/node-tunnel
Verifying credentials
Auth succeeded
Downloading latest binary
Extracting binary
Starting tunnel
Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at Object.spawn (node:child_process:757:9)
    at /data/src/node_modules/wdio-lambdatest-service/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:342:32
    at /data/src/node_modules/wdio-lambdatest-service/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:773:18
    at /data/src/node_modules/wdio-lambdatest-service/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:810:14
    at Object.onceWrapper (node:events:627:28)
    at Server.emit (node:events:513:28)
    at Server.emit (node:domain:489:12)
    at emitCloseNT (node:net:2135:8)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)

Could this be related to the release?

@vrockaibrx
Copy link
Author

I've been able to find the culprit, but at the moment I don't know how to fix it. The problem lies in the unzipper npm package:

.pipe(unzip.Extract({ path: destParentDir }))

For some reason when it unzips the LT file inside the docker image node:18-alpine the resulting LT file is corrupted - meaning, you cannot execute it on linux, it give you error like:

❯ /tmp/.lambdatest/v3/LT --version
bash: /tmp/.lambdatest/v3/LT: cannot execute binary file: Exec format error

@Shivanshu-lambdatest
Copy link
Contributor

Thanks, @vrockaibrx for highlighting this issue, however, the release of a new version should not impact the older versions. We will try & validate the working package for the Linux environment.

@vrockaibrx
Copy link
Author

Yeah, I was inspecting the changes in the release and I don't see what could have caused it. It's not really a problem in the node-tunnel code itself, but it breaks node-tunnel functionality. Anyway, the issue is easy to replicate.

Right now my workaround is to manually unzip the LT binary into the ./.lambdatest/v3/ directory, before running node-tunnel.

@DanielHaroldLane
Copy link
Contributor

Can confirm this is an issue. It's a very strange bug as well. I tried manually downloading the LT_Linux.zip file for 64 bit as defined in the config files and manually unzipped and that works. I also allowed the script to download the zip and extract it using unzipper. Strangely both extracted files have the same SHA256 sum.

Stranger still they both have the same permissions.

The code in node-tunnel seems fine. Can also confirm this was on node 18.

@vrockaibrx
Copy link
Author

@DanielHaroldLane they have the exact same size for me, but different sha sums (and contents). my wild guess would be a character encoding issue with unzipper npm package.

@Shivanshu-lambdatest
Copy link
Contributor

Shivanshu-lambdatest commented Apr 18, 2023

@vrockaibrx @DanielHaroldLane Will you be able to share any sample scripts to re-produce it worked fine at my end tried it on Linux, Mac & windows as well.

Also, could you please try older versions like 3.0.13 or 3.0.12 and share your findings? do give a try to the latest version as well.

@vrockaibrx
Copy link
Author

@Shivanshu-lambdatest , the LT team provided this test repo for me:
https://github.com/LambdaTest/sample-node-tunnel

When you try to run this repo inside:
image

@DanielHaroldLane
Copy link
Contributor

DanielHaroldLane commented Apr 19, 2023

@Shivanshu-lambdatest

@vrockaibrx @DanielHaroldLane Will you be able to share any sample scripts to re-produce it worked fine at my end tried it on Linux, Mac & windows as well.

Also, could you please try older versions like 3.0.13 or 3.0.12 and share your findings? do give a try to the latest version as well.

All I did was load this repo, add an .nvmrc file in the project root and set it to lts/hydrogen. I ran nvm use to switch to node 18 and installed dependencies using npm i. Then I updated the test script with my username/access key and ran the tests using npm run test. I'm on an Ubuntu derived Linux distro, x64. The same is happening on gitlab pipeline runners using an ubuntu image with the node 18 runtime.

I'm seeing the output:

`$ mocha tests --recursive

Tunnel runs successfully
Current version of Node Tunnel: 4.0.0
Verifying credentials
Auth succeeded
Downloading latest binary
Extracting binary
Starting tunnel
Tunnel successfully stopped`

I've had someone else reproduce this as well. As I say, it's also happening in pipelines. The LT binary after unzip can't be executed, it seems corrupt. The zip file itself is fine if manually extracted using a zip archive tool like the linux unzip command. If you let tunnel_library.js download and extract the zip and then try to execute the binary manually in a terminal it will output this:

exec format error

I think @vrockaibrx is correct. It could be a character encoding problem. I tried modifying the code to use node's inbuilt zlib library and the Inflate command as I noticed the zip is compressed using the deflate algorithm and that complains that the archive headers are incorrect.

The problem was unzipper. Using a different unzipping module resolved the issue. PR with the fix is open.

@DanielHaroldLane
Copy link
Contributor

I've fixed this issue by using a better maintained zip npm lib. Opening a PR shortly.

@Shivanshu-lambdatest
Copy link
Contributor

@DanielHaroldLane Thanks for the PR, version 4.0.1 has been released. This should solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants