Skip to content

InvalidStateError when running with Bun #22

@Alef-Keuffer

Description

@Alef-Keuffer

Bun version: 1.2.4
pgmock version: 1.0.3
OS: NixOS (24.11)

Error doesn't occur using tsx.

Minimal example:

// main.ts
import { PostgresMock } from "pgmock";

const mock = await PostgresMock.create();
const connectionString = await mock.listen(5440);
console.log({connectionString});

run bun main.ts will fail with

$ bun main.ts
3010 |       this.worker = new Worker(b);
3011 |       this.worker.onmessage = (c) => this.yield_callback(c.data);
3012 |       URL.revokeObjectURL(b);
3013 |     };
3014 |     D.prototype.yield = function(b, c) {
3015 |       this.worker.postMessage({ t: b, tick: c });
             ^
InvalidStateError: Worker has been terminated
DOMException {
  line: 2611,
  column: 30,
  sourceURL: "/home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js",
  stack: "postMessage@[native code]\n@/home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js:2611:30\n@/home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.
js:2572:15\n@/home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js:2558:19\n@/home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js:9865:18\n@/home/alef/D
ownloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js:12130:35\nd@/home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js:12118:26",
  code: 11,
  name: "InvalidStateError",
  message: "Worker has been terminated",
  INDEX_SIZE_ERR: 1,
  DOMSTRING_SIZE_ERR: 2,
  HIERARCHY_REQUEST_ERR: 3,
  WRONG_DOCUMENT_ERR: 4,
  INVALID_CHARACTER_ERR: 5,
  NO_DATA_ALLOWED_ERR: 6,
  NO_MODIFICATION_ALLOWED_ERR: 7,
  NOT_FOUND_ERR: 8,
  NOT_SUPPORTED_ERR: 9,
  INUSE_ATTRIBUTE_ERR: 10,
  INVALID_STATE_ERR: 11,
  SYNTAX_ERR: 12,
  INVALID_MODIFICATION_ERR: 13,
  NAMESPACE_ERR: 14,
  INVALID_ACCESS_ERR: 15,
  VALIDATION_ERR: 16,
  TYPE_MISMATCH_ERR: 17,
  SECURITY_ERR: 18,
  NETWORK_ERR: 19,
  ABORT_ERR: 20,
  URL_MISMATCH_ERR: 21,
  QUOTA_EXCEEDED_ERR: 22,
  TIMEOUT_ERR: 23,
  INVALID_NODE_TYPE_ERR: 24,
  DATA_CLONE_ERR: 25,
  toString: [Function: toString],
}
      at /home/alef/Downloads/report-pgmock-issue-with-bun/node_modules/pgmock/dist/main.js:3015:7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions