tidewave 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.4] - 2025-11-13
4
+
5
+ * Fix async messages on `project_eval`
6
+
3
7
  ## [0.5.3] - 2025-11-12
4
8
 
5
9
  * Make sure `instrumentation.ts` is compatible with webpack
package/dist/cli/index.js CHANGED
@@ -6725,31 +6725,34 @@ async function executeIsolated(request) {
6725
6725
  const packageRoot = dirname(require2.resolve("tidewave/package.json"));
6726
6726
  const workerPath = join(packageRoot, "dist/evaluation/eval_worker.js");
6727
6727
  const child = fork(workerPath, { silent: true });
6728
- const evaluation = {
6729
- success: false,
6730
- result: null,
6731
- stdout: "",
6732
- stderr: ""
6733
- };
6728
+ let result = null;
6729
+ const stdoutChunks = [];
6730
+ const stderrChunks = [];
6734
6731
  child.stdout?.on("data", (data) => {
6735
- evaluation.stdout += data.toString();
6732
+ stdoutChunks.push(data.toString());
6736
6733
  });
6737
6734
  child.stderr?.on("data", (data) => {
6738
- evaluation.stderr += data.toString();
6735
+ stderrChunks.push(data.toString());
6739
6736
  });
6740
6737
  child.on("message", (msg) => {
6741
6738
  if (msg.type === "result") {
6742
6739
  const { data, success } = msg;
6743
- evaluation.result = data;
6744
- evaluation.success = success;
6740
+ result = { success, result: data };
6741
+ child.send({ type: "finish" });
6745
6742
  }
6746
6743
  });
6747
6744
  child.on("exit", (code) => {
6745
+ if (result === null) {
6746
+ result = {
6747
+ success: false,
6748
+ result: `Evaluation process terminated unexpectedly with code ${code}`
6749
+ };
6750
+ }
6748
6751
  resolve({
6749
- success: evaluation.success && code === 0,
6750
- result: evaluation.result,
6751
- stdout: evaluation.stdout.trim(),
6752
- stderr: evaluation.stderr.trim()
6752
+ success: result.success,
6753
+ result: result.result,
6754
+ stdout: stdoutChunks.join(""),
6755
+ stderr: stderrChunks.join("")
6753
6756
  });
6754
6757
  });
6755
6758
  const { timeout } = request;
@@ -6758,12 +6761,12 @@ async function executeIsolated(request) {
6758
6761
  resolve({
6759
6762
  success: false,
6760
6763
  result: `Evaluation timed out after ${timeout} milliseconds`,
6761
- stdout: evaluation.stdout,
6762
- stderr: evaluation.stderr
6764
+ stdout: stdoutChunks.join(""),
6765
+ stderr: stderrChunks.join("")
6763
6766
  });
6764
6767
  }, timeout);
6765
6768
  child.on("exit", () => clearTimeout(timeoutId));
6766
- child.send(request);
6769
+ child.send({ type: "evaluate", request });
6767
6770
  });
6768
6771
  }
6769
6772
  var init_code_executor = () => {};
@@ -6784,7 +6787,7 @@ var init_src = __esm(() => {
6784
6787
  });
6785
6788
 
6786
6789
  // package.json
6787
- var name = "tidewave", version = "0.5.3", package_default;
6790
+ var name = "tidewave", version = "0.5.4", package_default;
6788
6791
  var init_package = __esm(() => {
6789
6792
  package_default = {
6790
6793
  name,
@@ -1,24 +1,28 @@
1
1
  // src/evaluation/eval_worker.ts
2
- process.on("message", async ({ code, args }) => {
2
+ process.on("message", async (message) => {
3
3
  if (!process.send) {
4
4
  console.error("[Tidewave] Unable to establish communication channel with code-executor.");
5
5
  process.exit(1);
6
6
  }
7
- try {
8
- const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
9
- const fn = new AsyncFunction(code);
10
- const result = await fn(...args);
11
- process.send({
12
- type: "result",
13
- success: true,
14
- data: (result ?? null) && result
15
- });
16
- } catch (error) {
17
- process.send({
18
- type: "result",
19
- success: false,
20
- data: new String(error)
21
- });
7
+ if (message.type === "evaluate") {
8
+ const { code, args } = message.request;
9
+ try {
10
+ const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
11
+ const fn = new AsyncFunction(code);
12
+ const result = await fn(...args);
13
+ process.send({
14
+ type: "result",
15
+ success: true,
16
+ data: (result ?? null) && result
17
+ });
18
+ } catch (error) {
19
+ process.send({
20
+ type: "result",
21
+ success: false,
22
+ data: new String(error)
23
+ });
24
+ }
25
+ } else if (message.type === "finish") {
26
+ process.exit(0);
22
27
  }
23
- process.exit(0);
24
28
  });
@@ -20137,7 +20137,7 @@ Defaults to 30000 (30 seconds).`),
20137
20137
  });
20138
20138
 
20139
20139
  // package.json
20140
- var name = "tidewave", version = "0.5.3", package_default;
20140
+ var name = "tidewave", version = "0.5.4", package_default;
20141
20141
  var init_package = __esm(() => {
20142
20142
  package_default = {
20143
20143
  name,
@@ -21031,31 +21031,34 @@ async function executeIsolated(request) {
21031
21031
  const packageRoot = dirname(require2.resolve("tidewave/package.json"));
21032
21032
  const workerPath = join(packageRoot, "dist/evaluation/eval_worker.js");
21033
21033
  const child = fork(workerPath, { silent: true });
21034
- const evaluation = {
21035
- success: false,
21036
- result: null,
21037
- stdout: "",
21038
- stderr: ""
21039
- };
21034
+ let result = null;
21035
+ const stdoutChunks = [];
21036
+ const stderrChunks = [];
21040
21037
  child.stdout?.on("data", (data) => {
21041
- evaluation.stdout += data.toString();
21038
+ stdoutChunks.push(data.toString());
21042
21039
  });
21043
21040
  child.stderr?.on("data", (data) => {
21044
- evaluation.stderr += data.toString();
21041
+ stderrChunks.push(data.toString());
21045
21042
  });
21046
21043
  child.on("message", (msg) => {
21047
21044
  if (msg.type === "result") {
21048
21045
  const { data, success } = msg;
21049
- evaluation.result = data;
21050
- evaluation.success = success;
21046
+ result = { success, result: data };
21047
+ child.send({ type: "finish" });
21051
21048
  }
21052
21049
  });
21053
21050
  child.on("exit", (code) => {
21051
+ if (result === null) {
21052
+ result = {
21053
+ success: false,
21054
+ result: `Evaluation process terminated unexpectedly with code ${code}`
21055
+ };
21056
+ }
21054
21057
  resolve({
21055
- success: evaluation.success && code === 0,
21056
- result: evaluation.result,
21057
- stdout: evaluation.stdout.trim(),
21058
- stderr: evaluation.stderr.trim()
21058
+ success: result.success,
21059
+ result: result.result,
21060
+ stdout: stdoutChunks.join(""),
21061
+ stderr: stderrChunks.join("")
21059
21062
  });
21060
21063
  });
21061
21064
  const { timeout } = request;
@@ -21064,12 +21067,12 @@ async function executeIsolated(request) {
21064
21067
  resolve({
21065
21068
  success: false,
21066
21069
  result: `Evaluation timed out after ${timeout} milliseconds`,
21067
- stdout: evaluation.stdout,
21068
- stderr: evaluation.stderr
21070
+ stdout: stdoutChunks.join(""),
21071
+ stderr: stderrChunks.join("")
21069
21072
  });
21070
21073
  }, timeout);
21071
21074
  child.on("exit", () => clearTimeout(timeoutId));
21072
- child.send(request);
21075
+ child.send({ type: "evaluate", request });
21073
21076
  });
21074
21077
  }
21075
21078
  var init_code_executor = () => {};
@@ -20137,7 +20137,7 @@ Defaults to 30000 (30 seconds).`),
20137
20137
  });
20138
20138
 
20139
20139
  // package.json
20140
- var name = "tidewave", version = "0.5.3", package_default;
20140
+ var name = "tidewave", version = "0.5.4", package_default;
20141
20141
  var init_package = __esm(() => {
20142
20142
  package_default = {
20143
20143
  name,
@@ -21031,31 +21031,34 @@ async function executeIsolated(request) {
21031
21031
  const packageRoot = dirname(require2.resolve("tidewave/package.json"));
21032
21032
  const workerPath = join(packageRoot, "dist/evaluation/eval_worker.js");
21033
21033
  const child = fork(workerPath, { silent: true });
21034
- const evaluation = {
21035
- success: false,
21036
- result: null,
21037
- stdout: "",
21038
- stderr: ""
21039
- };
21034
+ let result = null;
21035
+ const stdoutChunks = [];
21036
+ const stderrChunks = [];
21040
21037
  child.stdout?.on("data", (data) => {
21041
- evaluation.stdout += data.toString();
21038
+ stdoutChunks.push(data.toString());
21042
21039
  });
21043
21040
  child.stderr?.on("data", (data) => {
21044
- evaluation.stderr += data.toString();
21041
+ stderrChunks.push(data.toString());
21045
21042
  });
21046
21043
  child.on("message", (msg) => {
21047
21044
  if (msg.type === "result") {
21048
21045
  const { data, success } = msg;
21049
- evaluation.result = data;
21050
- evaluation.success = success;
21046
+ result = { success, result: data };
21047
+ child.send({ type: "finish" });
21051
21048
  }
21052
21049
  });
21053
21050
  child.on("exit", (code) => {
21051
+ if (result === null) {
21052
+ result = {
21053
+ success: false,
21054
+ result: `Evaluation process terminated unexpectedly with code ${code}`
21055
+ };
21056
+ }
21054
21057
  resolve({
21055
- success: evaluation.success && code === 0,
21056
- result: evaluation.result,
21057
- stdout: evaluation.stdout.trim(),
21058
- stderr: evaluation.stderr.trim()
21058
+ success: result.success,
21059
+ result: result.result,
21060
+ stdout: stdoutChunks.join(""),
21061
+ stderr: stderrChunks.join("")
21059
21062
  });
21060
21063
  });
21061
21064
  const { timeout } = request;
@@ -21064,12 +21067,12 @@ async function executeIsolated(request) {
21064
21067
  resolve({
21065
21068
  success: false,
21066
21069
  result: `Evaluation timed out after ${timeout} milliseconds`,
21067
- stdout: evaluation.stdout,
21068
- stderr: evaluation.stderr
21070
+ stdout: stdoutChunks.join(""),
21071
+ stderr: stderrChunks.join("")
21069
21072
  });
21070
21073
  }, timeout);
21071
21074
  child.on("exit", () => clearTimeout(timeoutId));
21072
- child.send(request);
21075
+ child.send({ type: "evaluate", request });
21073
21076
  });
21074
21077
  }
21075
21078
  var init_code_executor = () => {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tidewave",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Tidewave for JavaScript/Next.js",
5
5
  "keywords": [
6
6
  "typescript",