@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.16

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.
Files changed (235) hide show
  1. package/README.md +111 -101
  2. package/app_meta.ts +56 -54
  3. package/config/config.ts +60 -57
  4. package/config/secrets.ts +45 -52
  5. package/config/value.ts +23 -26
  6. package/cron/mod.ts +28 -29
  7. package/dist/app_meta.d.ts +52 -50
  8. package/dist/app_meta.d.ts.map +1 -1
  9. package/dist/app_meta.js +2 -2
  10. package/dist/app_meta.js.map +1 -1
  11. package/dist/config/config.d.ts +58 -55
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +8 -9
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/secrets.d.ts +45 -52
  16. package/dist/config/secrets.d.ts.map +1 -1
  17. package/dist/config/secrets.js +8 -9
  18. package/dist/config/secrets.js.map +1 -1
  19. package/dist/config/value.d.ts +20 -23
  20. package/dist/config/value.d.ts.map +1 -1
  21. package/dist/config/value.js +20 -23
  22. package/dist/config/value.js.map +1 -1
  23. package/dist/cron/mod.d.ts +26 -27
  24. package/dist/cron/mod.d.ts.map +1 -1
  25. package/dist/cron/mod.js +13 -14
  26. package/dist/cron/mod.js.map +1 -1
  27. package/dist/frontends/mod.d.ts +20 -19
  28. package/dist/frontends/mod.d.ts.map +1 -1
  29. package/dist/frontends/mod.js +20 -19
  30. package/dist/frontends/mod.js.map +1 -1
  31. package/dist/gateway/errors.d.ts +28 -30
  32. package/dist/gateway/errors.d.ts.map +1 -1
  33. package/dist/gateway/errors.js +29 -31
  34. package/dist/gateway/errors.js.map +1 -1
  35. package/dist/gateway/match.d.ts +54 -54
  36. package/dist/gateway/match.d.ts.map +1 -1
  37. package/dist/gateway/match.js +56 -56
  38. package/dist/gateway/match.js.map +1 -1
  39. package/dist/gateway/middleware.d.ts +62 -64
  40. package/dist/gateway/middleware.d.ts.map +1 -1
  41. package/dist/gateway/middleware.js +1 -1
  42. package/dist/gateway/middleware.js.map +1 -1
  43. package/dist/gateway/mod.d.ts +64 -67
  44. package/dist/gateway/mod.d.ts.map +1 -1
  45. package/dist/gateway/mod.js +72 -76
  46. package/dist/gateway/mod.js.map +1 -1
  47. package/dist/gateway/request.d.ts +138 -134
  48. package/dist/gateway/request.d.ts.map +1 -1
  49. package/dist/gateway/request.js +117 -108
  50. package/dist/gateway/request.js.map +1 -1
  51. package/dist/gateway/serve.d.ts +29 -34
  52. package/dist/gateway/serve.d.ts.map +1 -1
  53. package/dist/gateway/serve.js +51 -56
  54. package/dist/gateway/serve.js.map +1 -1
  55. package/dist/gateways/mod.d.ts +23 -21
  56. package/dist/gateways/mod.d.ts.map +1 -1
  57. package/dist/gateways/mod.js +25 -23
  58. package/dist/gateways/mod.js.map +1 -1
  59. package/dist/internal/runtime/napi/napi.cjs +1 -1
  60. package/dist/internal/runtime/napi/napi.d.cts +10 -3
  61. package/dist/internal/runtime/shutdown.d.ts +75 -57
  62. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  63. package/dist/internal/runtime/shutdown.js +88 -84
  64. package/dist/internal/runtime/shutdown.js.map +1 -1
  65. package/dist/log/logger.d.ts +43 -37
  66. package/dist/log/logger.d.ts.map +1 -1
  67. package/dist/log/logger.js +26 -25
  68. package/dist/log/logger.js.map +1 -1
  69. package/dist/metrics/mod.d.ts +133 -114
  70. package/dist/metrics/mod.d.ts.map +1 -1
  71. package/dist/metrics/mod.js +109 -101
  72. package/dist/metrics/mod.js.map +1 -1
  73. package/dist/otel.d.ts +6 -3
  74. package/dist/otel.d.ts.map +1 -1
  75. package/dist/otel.js +6 -3
  76. package/dist/otel.js.map +1 -1
  77. package/dist/pubsub/subscription.d.ts +88 -116
  78. package/dist/pubsub/subscription.d.ts.map +1 -1
  79. package/dist/pubsub/subscription.js +14 -17
  80. package/dist/pubsub/subscription.js.map +1 -1
  81. package/dist/pubsub/topic.d.ts +86 -113
  82. package/dist/pubsub/topic.d.ts.map +1 -1
  83. package/dist/pubsub/topic.js +68 -82
  84. package/dist/pubsub/topic.js.map +1 -1
  85. package/dist/reqctx/mod.d.ts +83 -86
  86. package/dist/reqctx/mod.d.ts.map +1 -1
  87. package/dist/reqctx/mod.js +39 -41
  88. package/dist/reqctx/mod.js.map +1 -1
  89. package/dist/services/index.d.ts +76 -75
  90. package/dist/services/index.d.ts.map +1 -1
  91. package/dist/services/index.js +73 -71
  92. package/dist/services/index.js.map +1 -1
  93. package/dist/shutdown/mod.d.ts +26 -25
  94. package/dist/shutdown/mod.d.ts.map +1 -1
  95. package/dist/shutdown/mod.js +26 -25
  96. package/dist/shutdown/mod.js.map +1 -1
  97. package/dist/storage/clickhouse/database.d.ts +113 -115
  98. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  99. package/dist/storage/clickhouse/database.js +65 -79
  100. package/dist/storage/clickhouse/database.js.map +1 -1
  101. package/dist/storage/clickhouse/errors.d.ts +25 -26
  102. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  103. package/dist/storage/clickhouse/errors.js +15 -17
  104. package/dist/storage/clickhouse/errors.js.map +1 -1
  105. package/dist/storage/clickhouse/mod.d.ts +10 -10
  106. package/dist/storage/clickhouse/mod.js +10 -10
  107. package/dist/storage/objects/bucket.d.ts +196 -225
  108. package/dist/storage/objects/bucket.d.ts.map +1 -1
  109. package/dist/storage/objects/bucket.js +71 -84
  110. package/dist/storage/objects/bucket.js.map +1 -1
  111. package/dist/storage/objects/error.d.ts +4 -4
  112. package/dist/storage/objects/error.js +4 -4
  113. package/dist/storage/postgres/database.d.ts +124 -149
  114. package/dist/storage/postgres/database.d.ts.map +1 -1
  115. package/dist/storage/postgres/database.js +98 -135
  116. package/dist/storage/postgres/database.js.map +1 -1
  117. package/dist/storage/postgres/errors.d.ts +42 -48
  118. package/dist/storage/postgres/errors.d.ts.map +1 -1
  119. package/dist/storage/postgres/errors.js +44 -51
  120. package/dist/storage/postgres/errors.js.map +1 -1
  121. package/dist/storage/postgres/interval.d.ts +19 -19
  122. package/dist/storage/postgres/interval.d.ts.map +1 -1
  123. package/dist/storage/postgres/interval.js +21 -21
  124. package/dist/storage/postgres/interval.js.map +1 -1
  125. package/dist/storage/redis/bitfield.d.ts +48 -23
  126. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  127. package/dist/storage/redis/bitfield.js +38 -19
  128. package/dist/storage/redis/bitfield.js.map +1 -1
  129. package/dist/storage/redis/command.d.ts +16 -12
  130. package/dist/storage/redis/command.d.ts.map +1 -1
  131. package/dist/storage/redis/command.js +16 -12
  132. package/dist/storage/redis/command.js.map +1 -1
  133. package/dist/storage/redis/commands.d.ts +99 -100
  134. package/dist/storage/redis/commands.d.ts.map +1 -1
  135. package/dist/storage/redis/commands.js +84 -85
  136. package/dist/storage/redis/commands.js.map +1 -1
  137. package/dist/storage/redis/database.d.ts +138 -122
  138. package/dist/storage/redis/database.d.ts.map +1 -1
  139. package/dist/storage/redis/database.js +120 -101
  140. package/dist/storage/redis/database.js.map +1 -1
  141. package/dist/storage/redis/mod.d.ts +52 -48
  142. package/dist/storage/redis/mod.d.ts.map +1 -1
  143. package/dist/storage/redis/mod.js +52 -48
  144. package/dist/storage/redis/mod.js.map +1 -1
  145. package/dist/storage/redis/options.d.ts +26 -24
  146. package/dist/storage/redis/options.d.ts.map +1 -1
  147. package/dist/storage/redis/options.js.map +1 -1
  148. package/dist/storage/redis/pubsub.d.ts +16 -16
  149. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  150. package/dist/storage/redis/pubsub.js +14 -14
  151. package/dist/storage/redis/pubsub.js.map +1 -1
  152. package/dist/storage/redis/reply.d.ts +80 -72
  153. package/dist/storage/redis/reply.d.ts.map +1 -1
  154. package/dist/storage/redis/reply.js +53 -46
  155. package/dist/storage/redis/reply.js.map +1 -1
  156. package/dist/storage/redis/scan.d.ts +4 -4
  157. package/dist/storage/redis/scan.d.ts.map +1 -1
  158. package/dist/storage/redis/scan.js +6 -6
  159. package/dist/storage/redis/scan.js.map +1 -1
  160. package/dist/storage/redis/script.d.ts +28 -21
  161. package/dist/storage/redis/script.d.ts.map +1 -1
  162. package/dist/storage/redis/script.js +29 -22
  163. package/dist/storage/redis/script.js.map +1 -1
  164. package/dist/storage/redis/target.d.ts +17 -1
  165. package/dist/storage/redis/target.d.ts.map +1 -1
  166. package/dist/storage/redis/target.js +30 -1
  167. package/dist/storage/redis/target.js.map +1 -1
  168. package/dist/storage/redis/wire.d.ts +6 -6
  169. package/dist/storage/redis/wire.d.ts.map +1 -1
  170. package/dist/storage/redis/wire.js +6 -6
  171. package/dist/storage/redis/wire.js.map +1 -1
  172. package/dist/testing/mod.d.ts +83 -88
  173. package/dist/testing/mod.d.ts.map +1 -1
  174. package/dist/testing/mod.js +75 -81
  175. package/dist/testing/mod.js.map +1 -1
  176. package/dist/testing/playwright.d.ts +28 -32
  177. package/dist/testing/playwright.d.ts.map +1 -1
  178. package/dist/testing/playwright.js +22 -27
  179. package/dist/testing/playwright.js.map +1 -1
  180. package/dist/testing/puppeteer.d.ts +11 -12
  181. package/dist/testing/puppeteer.d.ts.map +1 -1
  182. package/dist/testing/puppeteer.js +17 -18
  183. package/dist/testing/puppeteer.js.map +1 -1
  184. package/dist/testing/system.d.ts +72 -90
  185. package/dist/testing/system.d.ts.map +1 -1
  186. package/dist/testing/system.js +90 -107
  187. package/dist/testing/system.js.map +1 -1
  188. package/dist/tsconfig.build.tsbuildinfo +1 -1
  189. package/frontends/mod.test.ts +6 -2
  190. package/frontends/mod.ts +20 -19
  191. package/gateway/errors.ts +30 -32
  192. package/gateway/match.ts +61 -57
  193. package/gateway/middleware.ts +62 -64
  194. package/gateway/mod.ts +73 -76
  195. package/gateway/request.ts +143 -140
  196. package/gateway/serve.ts +58 -63
  197. package/gateways/mod.ts +25 -23
  198. package/internal/runtime/napi/napi.cjs +1 -1
  199. package/internal/runtime/napi/napi.d.cts +10 -3
  200. package/internal/runtime/shutdown.ts +113 -101
  201. package/log/logger.test.ts +8 -0
  202. package/log/logger.ts +48 -45
  203. package/metrics/mod.ts +138 -122
  204. package/otel.ts +6 -3
  205. package/package.json +1 -1
  206. package/pubsub/subscription.ts +93 -123
  207. package/pubsub/topic.ts +96 -130
  208. package/reqctx/mod.ts +83 -86
  209. package/services/index.ts +78 -78
  210. package/shutdown/mod.ts +26 -25
  211. package/storage/clickhouse/database.ts +115 -129
  212. package/storage/clickhouse/errors.ts +27 -29
  213. package/storage/clickhouse/mod.ts +10 -10
  214. package/storage/objects/bucket.ts +209 -239
  215. package/storage/objects/error.ts +4 -4
  216. package/storage/postgres/database.ts +131 -164
  217. package/storage/postgres/errors.ts +45 -52
  218. package/storage/postgres/interval.ts +21 -21
  219. package/storage/redis/bitfield.ts +51 -26
  220. package/storage/redis/command.ts +16 -12
  221. package/storage/redis/commands.ts +99 -100
  222. package/storage/redis/database.ts +145 -123
  223. package/storage/redis/mod.ts +52 -48
  224. package/storage/redis/options.ts +26 -24
  225. package/storage/redis/pubsub.ts +14 -14
  226. package/storage/redis/redis.test.ts +17 -2
  227. package/storage/redis/reply.ts +85 -77
  228. package/storage/redis/scan.ts +6 -6
  229. package/storage/redis/script.ts +29 -22
  230. package/storage/redis/target.ts +34 -1
  231. package/storage/redis/wire.ts +8 -8
  232. package/testing/mod.ts +99 -105
  233. package/testing/playwright.ts +32 -37
  234. package/testing/puppeteer.ts +22 -23
  235. package/testing/system.ts +117 -133
package/log/logger.ts CHANGED
@@ -4,7 +4,7 @@ import {encodeLog} from '../internal/runtime/napi/napi.cjs';
4
4
  import {writeStderr} from './stderr';
5
5
 
6
6
  /**
7
- * A field value we support logging
7
+ * A field value supported by structured logging.
8
8
  */
9
9
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
10
  // @ts-expect-error
@@ -12,7 +12,7 @@ export type FieldValue =
12
12
  string | number | boolean | null | undefined | FieldsObject | FieldValue[];
13
13
 
14
14
  /**
15
- * A map of fields that can be logged
15
+ * A map of structured fields attached to a log record.
16
16
  */
17
17
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
18
  // @ts-expect-error
@@ -27,10 +27,10 @@ export enum LogLevel {
27
27
  Fatal,
28
28
  }
29
29
 
30
- /** A level above every other: nothing is logged. */
30
+ /** Sentinel level above all log levels; disables logging completely. */
31
31
  export const OFF = LogLevel.Fatal + 1;
32
32
 
33
- /** Each level's name, as `ENCORE_LOG` gives it. */
33
+ /** Level names recognized by `ENCORE_LOG`. */
34
34
  const LEVELS: Record<LogLevel, string> = {
35
35
  [LogLevel.Trace]: 'trace',
36
36
  [LogLevel.Debug]: 'debug',
@@ -40,7 +40,10 @@ const LEVELS: Record<LogLevel, string> = {
40
40
  [LogLevel.Fatal]: 'fatal',
41
41
  };
42
42
 
43
- /** The level a name (any case) or `off` stands for; trace otherwise. */
43
+ /**
44
+ * Parses a case-insensitive log level name or `"off"`, defaulting to
45
+ * {@link LogLevel.Trace} for unrecognized or empty values.
46
+ */
44
47
  export function parseLevel(name: string | undefined): LogLevel {
45
48
  const v = name?.toLowerCase();
46
49
  if (v === 'off') return OFF;
@@ -50,48 +53,52 @@ export function parseLevel(name: string | undefined): LogLevel {
50
53
 
51
54
  /** @internal */
52
55
  export interface LoggerOptions {
53
- /** The lowest level logged. */
56
+ /** Minimum level to emit. */
54
57
  level: LogLevel;
55
- /** The `logger` of every record. */
58
+ /** Logger name recorded on each log line. */
56
59
  name?: string;
57
- /** Attributes of every record. */
60
+ /** Default attributes attached to every log record. */
58
61
  fields?: FieldsObject;
59
- /** Where lines go; stderr by default. */
62
+ /** Sink for encoded log lines; defaults to stderr. */
60
63
  write?: (line: Buffer) => void;
61
64
  }
62
65
 
63
- /** A record's parts besides its level and the logger's name. */
66
+ /** Structured fields for a log record beyond its level and logger name. */
64
67
  export interface RecordParts {
65
- /** When the record was made; absent: now. */
68
+ /** Timestamp in Unix milliseconds; defaults to the current time. */
66
69
  timeUnixMillis?: number;
67
- message: string;
68
- /** The span's 25-byte context: trace id, span id, flags. */
70
+ message?: string;
71
+ /** 25-byte encoded span context (trace ID, span ID, trace flags). */
69
72
  spanCtx?: Buffer;
70
73
  exceptionType?: string;
71
74
  exceptionMessage?: string;
72
- /** The stack trace in JavaScript's format. */
75
+ /** JavaScript stack trace string. */
73
76
  exceptionStacktrace?: string;
74
- /** The calling function's name. */
77
+ /** Calling function name. */
75
78
  codeFunction?: string;
76
- /** The caller's source file, line, and column. */
79
+ /** Caller source file, line, and column. */
77
80
  codeFile?: string;
78
81
  codeLine?: number;
79
82
  codeColumn?: number;
80
- /** The runtime module a line of the runtime's own comes from; such a
81
- * line logs under the runtime's logger, in place of the logger's name. */
83
+ /**
84
+ * Runtime module target for internal runtime logs; replaces the logger name
85
+ * with the runtime logger when set.
86
+ */
82
87
  runtimeTarget?: string;
83
- /** A JSON object of the user's attributes. */
88
+ /** JSON-encoded object of user attributes. */
84
89
  attrsJson?: string;
85
90
  }
86
91
 
87
92
  /**
88
- * A structured logger. Each call prints a log record on stderr, one line in
89
- * the Encore log format, with the logger's name, the logger's and the call's
90
- * fields as attributes, and the active span's ids. The SDK core encodes the
91
- * line; it needs the native library, not the runtime. An attribute named
92
- * like a reserved key is that field when valid, `raw.<key>` otherwise; one
93
- * named like a key of the record's exception is `raw.<key>`.
94
- * Lines are written synchronously; none is lost on `process.exit`.
93
+ * Structured logger that writes one Encore-formatted log record per line to
94
+ * stderr, including the logger name, bound and per-call attributes, and active
95
+ * span IDs.
96
+ *
97
+ * Lines are encoded by the native SDK core without requiring the full runtime,
98
+ * and are written synchronously so no records are lost on `process.exit`.
99
+ * Attributes colliding with reserved log keys are promoted when valid or stored
100
+ * under `raw.<key>` otherwise; attributes colliding with exception fields are
101
+ * always stored under `raw.<key>`.
95
102
  */
96
103
  export class Logger {
97
104
  private readonly level: LogLevel;
@@ -108,22 +115,22 @@ export class Logger {
108
115
  }
109
116
 
110
117
  /**
111
- * Returns a new logger with the specified level.
118
+ * Returns a new logger with the specified minimum level.
112
119
  */
113
120
  withLevel(level: LogLevel): Logger {
114
121
  return new Logger({...this.options(), level});
115
122
  }
116
123
 
117
124
  /**
118
- * Returns a new logger named `name`, the `logger` of its records, with
119
- * this logger's level and fields.
125
+ * Returns a new logger with the given `name` (recorded as `logger` on each
126
+ * log line), inheriting this logger's level and fields.
120
127
  */
121
128
  withName(name: string): Logger {
122
129
  return new Logger({...this.options(), name});
123
130
  }
124
131
 
125
132
  /**
126
- * Returns a new logger with the given fields added to the context.
133
+ * Returns a new logger with the given fields merged into its default context.
127
134
  */
128
135
  with(fields: FieldsObject): Logger {
129
136
  return new Logger({
@@ -133,28 +140,28 @@ export class Logger {
133
140
  }
134
141
 
135
142
  /**
136
- * Trace logs a message at the trace level.
143
+ * Logs a message at the trace level.
137
144
  */
138
145
  trace(msg: string, fields?: FieldsObject) {
139
146
  this.log(LogLevel.Trace, msg, fields);
140
147
  }
141
148
 
142
149
  /**
143
- * Debug logs a message at the debug level.
150
+ * Logs a message at the debug level.
144
151
  */
145
152
  debug(msg: string, fields?: FieldsObject) {
146
153
  this.log(LogLevel.Debug, msg, fields);
147
154
  }
148
155
 
149
156
  /**
150
- * Info logs a message at the info level.
157
+ * Logs a message at the info level.
151
158
  */
152
159
  info(msg: string, fields?: FieldsObject) {
153
160
  this.log(LogLevel.Info, msg, fields);
154
161
  }
155
162
 
156
163
  /**
157
- * Warn logs a message at the warn level.
164
+ * Logs a message or error at the warn level.
158
165
  */
159
166
  warn(err: Error | unknown, fields?: FieldsObject): void;
160
167
  warn(err: Error | unknown, msg: string, fields?: FieldsObject): void;
@@ -164,7 +171,7 @@ export class Logger {
164
171
  }
165
172
 
166
173
  /**
167
- * Error logs a message at the error level.
174
+ * Logs a message or error at the error level.
168
175
  */
169
176
  error(err: Error | unknown, fields?: FieldsObject): void;
170
177
  error(err: Error | unknown, msg: string, fields?: FieldsObject): void;
@@ -174,7 +181,7 @@ export class Logger {
174
181
  }
175
182
 
176
183
  /**
177
- * Fatal logs a message at the fatal level.
184
+ * Logs a message or error at the fatal level.
178
185
  */
179
186
  fatal(err: Error | unknown, fields?: FieldsObject): void;
180
187
  fatal(err: Error | unknown, msg: string, fields?: FieldsObject): void;
@@ -201,7 +208,7 @@ export class Logger {
201
208
  if (level < this.level) return;
202
209
 
203
210
  let err: Error | undefined;
204
- let msg: string;
211
+ let msg: string | undefined;
205
212
  let fields: FieldsObject | undefined;
206
213
  if (typeof errOrMsg === 'string') {
207
214
  // log(msg, fields?)
@@ -217,7 +224,6 @@ export class Logger {
217
224
  msg = msgOrFields;
218
225
  fields = possibleFields as FieldsObject | undefined;
219
226
  } else {
220
- msg = '';
221
227
  fields = msgOrFields as FieldsObject | undefined;
222
228
  }
223
229
  }
@@ -234,8 +240,7 @@ export class Logger {
234
240
  }
235
241
 
236
242
  /**
237
- * Prints a record of `parts` under the logger's name, at or above the
238
- * logger's level.
243
+ * Writes a log record if `level` is at or above this logger's minimum level.
239
244
  * @internal
240
245
  */
241
246
  emit(level: LogLevel, parts: RecordParts): void {
@@ -248,8 +253,7 @@ export class Logger {
248
253
  }
249
254
  }
250
255
 
251
- /** A record as a line in the Encore log format; `severity` is the
252
- * OpenTelemetry severity number. */
256
+ /** Encodes a log record in the Encore format using an OpenTelemetry severity number. */
253
257
  function encode(
254
258
  severity: number,
255
259
  logger: string | undefined,
@@ -273,7 +277,7 @@ function encode(
273
277
  );
274
278
  }
275
279
 
276
- /** `span` in its 25-byte wire form: trace id, span id, flags. */
280
+ /** Encodes `span` into its 25-byte wire form (trace ID, span ID, flags). */
277
281
  function spanBytes(span: SpanContext): Buffer {
278
282
  const b = Buffer.allocUnsafe(25);
279
283
  b.write(span.traceId, 0, 16, 'hex');
@@ -282,8 +286,7 @@ function spanBytes(span: SpanContext): Buffer {
282
286
  return b;
283
287
  }
284
288
 
285
- /** `attrs` as a JSON object: bigints as strings, errors as their string,
286
- * `undefined` left out; a value JSON cannot hold (a cycle) as its string. */
289
+ /** Serializes `attrs` to JSON, converting bigints, errors, and non-serializable values to strings. */
287
290
  function attrsJson(attrs: Record<string, unknown>): string {
288
291
  try {
289
292
  return JSON.stringify(attrs, replacer);