Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): device hub error diagnostics keep emoji whole at the 2,000-character limit #48287

Opensaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48287/headopened View on GitHub

Showing 2 changed files with 21 additions and 1 deletion.

x
0 of 2 viewed, 2 left
1 addition and 1 deletionapps/server/src/device/DeviceHubOperations.tsModified
View file
@@ -58,7 +58,7 @@
​
// Hub diagnostics can carry a whole stderr dump.
const boundDiagnostics = (text: string) =>
- text.length > 2_000 ? `${text.slice(0, 1_999)}…` : text;
+ text.length > 2_000 ? `${text.slice(0, 1_999).replace(/[\uD800-\uDBFF]$/u, "")}…` : text;
​
// The hub's `error` is a util.inspect of Node's exec error; the stack and the
// inspected fields follow the first frame, so keep the lines before it.
20 additions and 0 deletionsapps/server/src/device/DeviceService.test.tsModified
View file
@@ -1232,6 +1232,26 @@
+it.effect("keeps hub boot diagnostics well-formed when truncating at an emoji", () =>
+ Effect.gen(function* () {
+ const prefix = "a".repeat(1_998);
+ const { service } = yield* fixture(Effect.void, `${prefix}🚀${"b".repeat(10)}`);
+ yield* service.configure({ enabled: true });
+ const error = yield* service
+ .open({
+ threadId: ThreadId.make("emoji-boot-failure"),
+ deviceId: "Pixel_API_35",
+ platform: "android",
+ })
+ .pipe(Effect.flip);
+ expect(error).toBeInstanceOf(DeviceBootError);