diff options
author | 2023-07-20 18:49:10 -0300 | |
---|---|---|
committer | 2023-07-20 14:49:10 -0700 | |
commit | 99da0ae54b45c152eb26bd72b74765695d619bdc (patch) | |
tree | b198e25a080587089bd04e3102485000186b4476 /test/js | |
parent | 4686f5395eabe88250af31014adbfe91949166db (diff) | |
download | bun-99da0ae54b45c152eb26bd72b74765695d619bdc.tar.gz bun-99da0ae54b45c152eb26bd72b74765695d619bdc.tar.zst bun-99da0ae54b45c152eb26bd72b74765695d619bdc.zip |
fix start delay on Worker (#3707)
* fix start delay on Worker
* fmt
* add delay test
Diffstat (limited to 'test/js')
-rw-r--r-- | test/js/third_party/comlink/comlink.test.ts | 15 | ||||
-rw-r--r-- | test/js/third_party/comlink/package.json | 6 | ||||
-rw-r--r-- | test/js/third_party/comlink/worker.fixture.ts | 9 |
3 files changed, 30 insertions, 0 deletions
diff --git a/test/js/third_party/comlink/comlink.test.ts b/test/js/third_party/comlink/comlink.test.ts new file mode 100644 index 000000000..77d810950 --- /dev/null +++ b/test/js/third_party/comlink/comlink.test.ts @@ -0,0 +1,15 @@ +import { test, expect, describe } from "bun:test"; +import { join } from "path"; +import * as Comlink from "comlink"; + +describe("comlink", () => { + test("should start without big delay", async () => { + const worker = new Worker(join(import.meta.dir, "worker.fixture.ts")); + const obj = Comlink.wrap(worker); + const start = performance.now(); + //@ts-ignore + await obj.counter; + const end = performance.now(); + expect(end - start).toBeLessThan(100); + }); +}); diff --git a/test/js/third_party/comlink/package.json b/test/js/third_party/comlink/package.json new file mode 100644 index 000000000..707196be3 --- /dev/null +++ b/test/js/third_party/comlink/package.json @@ -0,0 +1,6 @@ +{ + "name": "comlink", + "dependencies": { + "comlink": "4.4.1" + } +} diff --git a/test/js/third_party/comlink/worker.fixture.ts b/test/js/third_party/comlink/worker.fixture.ts new file mode 100644 index 000000000..1cfcfbe9f --- /dev/null +++ b/test/js/third_party/comlink/worker.fixture.ts @@ -0,0 +1,9 @@ +import * as Comlink from "comlink"; +const obj = { + counter: 0, + inc() { + this.counter++; + }, +}; + +Comlink.expose(obj); |