@encore.dev/sdk 2.0.0-beta.10 → 2.0.0-beta.13

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/services/index.ts CHANGED
@@ -57,13 +57,13 @@
57
57
  * A generated call that fails throws a {@link CallError}, whatever kind of
58
58
  * API it calls, which `instanceof CallError` tells from any other error. Its
59
59
  * code is the service's answer to the caller, not the caller's to its own
60
- * clients: one an `@encore.dev/api` handler lets escape answers internal, as
60
+ * clients: one an `@encore.dev/framework` handler lets escape answers internal, as
61
61
  * any error but an APIError does. A handler answers with a code of its own
62
62
  * where it means one, and {@link unlessNotFound} makes a `not_found` failure
63
63
  * `undefined`, for a call for something that may not be there:
64
64
  *
65
65
  * ```ts
66
- * import {APIError} from "@encore.dev/api";
66
+ * import {APIError} from "@encore.dev/framework";
67
67
  * import {CallError, unlessNotFound} from "@encore.dev/sdk/services";
68
68
  *
69
69
  * try {
@@ -1,4 +1,5 @@
1
1
  import {expect, test} from 'bun:test';
2
+ import {join} from 'node:path';
2
3
 
3
4
  // The native runtime exports completed public spans without global registration.
4
5
  test('public spans reach the native OTLP destination with parents, errors, and log correlation', async () => {
@@ -19,8 +20,9 @@ test('public spans reach the native OTLP destination with parents, errors, and l
19
20
  process.execPath,
20
21
  '-e',
21
22
  `
22
- import { instrumentHTTP, span } from "${import.meta.dir}/mod";
23
- import log from "${import.meta.dir}/../log/index";
23
+ import { instrumentHTTP, span } from ${JSON.stringify(join(import.meta.dir, 'mod'))};
24
+ import log from ${JSON.stringify(join(import.meta.dir, '..', 'log', 'index'))};
25
+ import { begin, completed } from ${JSON.stringify(join(import.meta.dir, '..', 'shutdown', 'mod'))};
24
26
  await instrumentHTTP(() => span("order_request", async () => {
25
27
  await new Promise(resolve => setTimeout(resolve, 1));
26
28
  span("validate_order", current => {
@@ -46,8 +48,11 @@ test('public spans reach the native OTLP destination with parents, errors, and l
46
48
  try {
47
49
  await instrumentHTTP(() => {throw new TypeError("handler failed");})(new Request("https://shop.test/throw"));
48
50
  } catch {}
49
- setInterval(() => {}, 1000);
50
51
  console.log("ready");
52
+ // The shutdown flushes the spans, begun here rather than by a signal,
53
+ // which Windows has none of to send.
54
+ begin();
55
+ process.exit((await completed()) === "success" ? 0 : 1);
51
56
  `,
52
57
  ],
53
58
  cwd: import.meta.dir,
@@ -70,7 +75,6 @@ test('public spans reach the native OTLP destination with parents, errors, and l
70
75
  stdout += new TextDecoder().decode(value);
71
76
  if (stdout.includes('ready')) break;
72
77
  }
73
- proc.kill('SIGTERM');
74
78
  expect(await proc.exited).toBe(0);
75
79
  expect(stdout).toContain('ready');
76
80
  const exported = received.flatMap(body =>