aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-07-20 18:49:10 -0300
committerGravatar GitHub <noreply@github.com> 2023-07-20 14:49:10 -0700
commit99da0ae54b45c152eb26bd72b74765695d619bdc (patch)
treeb198e25a080587089bd04e3102485000186b4476 /test/js
parent4686f5395eabe88250af31014adbfe91949166db (diff)
downloadbun-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.ts15
-rw-r--r--test/js/third_party/comlink/package.json6
-rw-r--r--test/js/third_party/comlink/worker.fixture.ts9
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);