near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 22 forks source link

TypeError: unexpected type, use Uint8Array #236

Closed gtsonevv closed 3 months ago

gtsonevv commented 4 months ago

TypeError: unexpected type, use Uint8Array when I try to initialize a Worker in 'jsdom' environment with jest.

my code:

beforeAll(async () => {
    worker = await Worker.init();
});

jest.config.js:

module.exports = {
    preset: 'ts-jest',
    collectCoverage: true,
    testEnvironment: 'jsdom'
}

Error:

Screenshot 2024-02-21 at 7 55 27
gtsonevv commented 4 months ago

There is a bugfix related to this bug in the latest version of near-api-js(3.0.2), updating the near-api-js dependency in near-workspaces-js could potentially fix this issue.

gtsonevv commented 4 months ago

It has been verified by our team, updating to the latest version of near-api-js will fix this issue.

fospring commented 4 months ago

@gtsonevv when I update near-api-js to v3.0.3,the ci task failed with Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory: https://github.com/near/near-workspaces-js/actions/runs/8159537274/job/22304059459?pr=238. Is there any changes in near-api-js will increase the memory usage?

gtsonevv commented 4 months ago

Hey @fospring,

borsh.deserialize(schema, StatusMessage, data);

and

borsh.serialize(schema, statusMessage);

from 02.patch-state.ava.ts seem to be causing this issue but I'm still not sure why.

fospring commented 3 months ago

Hey @gtsonevv, it seems no for this reason, I just skipped this test