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

Refigure gc tests #612

Closed
wants to merge 7 commits into from
Closed

Refigure gc tests #612

wants to merge 7 commits into from

Conversation

rotu
Copy link
Contributor

@rotu rotu commented Jun 11, 2024

Instead of using weak-napi, use the built-in WeakRef.
Use the native garbage collector with {type: 'major', execution: 'async'}.
If gc is not available and GC tests not explicitly skipped, fail test explicitly.

Replace weak-napi with built in WeakRef
@rotu rotu changed the title bump workflow versions Refigure gc tests Jun 17, 2024
tsconfig.json Outdated Show resolved Hide resolved
Copy link
Member

@aminya aminya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests fail with this error:

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'SourceFileObject'
    |     property 'statements' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'NodeObject'
    --- property 'parent' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:845:17)
    at process.target.send (node:internal/child_process:745:19)
    at /home/runner/work/zeromq.js/zeromq.js/node_modules/.pnpm/[email protected]/node_modules/workerpool/src/worker.js:139:22

@rotu
Copy link
Contributor Author

rotu commented Jun 17, 2024

The tests fail with this error:

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'SourceFileObject'
    |     property 'statements' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'NodeObject'
    --- property 'parent' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:845:17)
    at process.target.send (node:internal/child_process:745:19)
    at /home/runner/work/zeromq.js/zeromq.js/node_modules/.pnpm/[email protected]/node_modules/workerpool/src/worker.js:139:22

That's interesting.... I can see that here. It's failing when trying to send an error from the Typescript compiler. Curious why this didn't turn up earlier...

"⨯ Unable to compile TypeScript:\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m7\u001b[0m:\u001b[93m1\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m7\u001b[0m describe(\"context process exit\", function () {\r\n\u001b[7m \u001b[0m \u001b[91m~~~~~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m8\u001b[0m:\u001b[93m3\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m8\u001b[0m   describe(\"with default context\", function () {\r\n\u001b[7m \u001b[0m \u001b[91m  ~~~~~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m9\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m9\u001b[0m     it(\"should occur when sockets are closed\", async function () {\r\n\u001b[7m \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m10\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m10\u001b[0m       this.slow(200)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m21\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m21\u001b[0m     it(\"should occur when sockets are not closed\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m22\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m22\u001b[0m       this.slow(200)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m31\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m31\u001b[0m     it(\"should not occur when sockets are open and polling\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m32\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m32\u001b[0m       this.slow(1000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m45\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m45\u001b[0m     it(\"should produce warning when messages are queued with blocky\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m46\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m46\u001b[0m       this.slow(2000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m69\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m69\u001b[0m     it(\"should produce warning when messages are queued without blocky\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m70\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m70\u001b[0m       this.slow(2000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m86\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m86\u001b[0m     it(\"should not produce warning when messages are queued for a short time\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m87\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m87\u001b[0m       this.slow(1000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m101\u001b[0m:\u001b[93m3\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m101\u001b[0m   describe(\"with custom context\", function () {\r\n\u001b[7m   \u001b[0m \u001b[91m  ~~~~~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m102\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m102\u001b[0m     it(\"should occur when sockets are closed\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m103\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m103\u001b[0m       this.slow(200)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m115\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m115\u001b[0m     it(\"should occur when sockets are closed and context is gced\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m116\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m116\u001b[0m       this.slow(200)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m133\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m133\u001b[0m     it(\"should occur when sockets are not closed\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m134\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m134\u001b[0m       this.slow(200)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m144\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m144\u001b[0m     it(\"should not occur when sockets are open and polling\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m145\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m145\u001b[0m       this.slow(1000)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n"

@rotu rotu marked this pull request as ready for review June 17, 2024 23:02
@aminya
Copy link
Member

aminya commented Jun 18, 2024

Yes, please revert any changes other than the weak-napi changes. Let's get the tests running again.

@aminya
Copy link
Member

aminya commented Jun 18, 2024

I moved these changes to #631

@aminya aminya closed this in #631 Jun 18, 2024
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

Successfully merging this pull request may close these issues.

2 participants