Closed itegulov closed 1 month ago
This also has memory leakage as a side effect:
To replicate: use Node v18.6, attempt to run workspaces-js tests for https://github.com/near-examples/FT
I'm encountering a similar issue when trying to run integration tests from create-near-app.
Sample code that results in a kill Node 18:
import anyTest, { TestFn } from 'ava';
import * as path from "path";
const test = anyTest as TestFn<{
worker: Worker;
accounts: Record<string, NearAccount>;
}>;
test( "create sub-account", async (t) => {
const worker = await Worker.init();
const root = worker.rootAccount;
// Hangs on this line w/ Node 18. Also hangs on deploy contract and others.
const contract = await root.createSubAccount("test-account");
t.context.worker = worker;
t.context.accounts = { root, contract };
});
This bug turns out to be due to an issue with node name resolution in Node18. I'll push a PR which addresses it.
@volovyks @ailisp we have come across this same issue today using node 19.8.0
.
This issue is affecting at least the example repos referenced by https://docs.near.org/develop/quickstart-guide , whose integration tests uses workspaces-js
Exact line it's getting stuck is:
For those who are new to node.js/ javascript/typescript, a temporary workaround is to downgrade node:
First, install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm --version # Verify installation
Then, downgrade node
nvm install v16.17.1
nvm use v16.17.1
Now, integration tests will run fine with downgraded node.
git clone https://github.com/near-examples/hello-near-rust
cd hello-near-rust
npm install
npm run test:integration
If you install node 17.9.0/18.2.0 (using
nvm
or through other means) and runyarn test
in theworkspaces-js
root directory all tests will fail with the following error:Rejected promise returned by test. Reason:
Error (TypedError)
{ context: undefined, type: 'RetriesExceeded', message: 'Exceeded 10 attempts for http://localhost:1026.', }
› Object.fetchJson (node_modules/near-api-js/lib/utils/web.js:47:15) › async node_modules/near-api-js/lib/providers/json-rpc-provider.js:312:34 › async Object.exponentialBackoff [as default] (node_modules/near-api-js/lib/utils/exponential-backoff.js:7:24) › async JsonRpcProvider.sendJsonRpc (node_modules/near-api-js/lib/providers/json-rpc-provider.js:304:26) › async JsonRpcProvider.query (node_modules/near-api-js/lib/providers/json-rpc-provider.js:116:22) › async Account.findAccessKey (node_modules/near-api-js/lib/account.js:186:31) › async Account.signTransaction (node_modules/near-api-js/lib/account.js:91:31) › async node_modules/near-api-js/lib/account.js:118:34 › async Object.exponentialBackoff [as default] (node_modules/near-api-js/lib/utils/exponential-backoff.js:7:24) › async Account.signAndSendTransactionV2 (node_modules/near-api-js/lib/account.js:117:24)
The last Node.js that works for me is 16.15.0