GitHub Actions commited on
Commit
cf2a028
·
1 Parent(s): 5eab11d

sync from abhijitramesh/webgpu-bench@199819e9a5

Browse files
Files changed (2) hide show
  1. js/run/bench-worker.js +35 -1
  2. js/run/controller.js +22 -6
js/run/bench-worker.js CHANGED
@@ -233,6 +233,40 @@ function parseBenchResult(label, raw) {
233
  return r;
234
  }
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  self.onmessage = async (e) => {
237
  const { type } = e.data || {};
238
  if (type !== 'run') {
@@ -247,7 +281,7 @@ self.onmessage = async (e) => {
247
  type: 'result',
248
  record: {
249
  status: 'error',
250
- error: err?.message || String(err),
251
  metrics: null,
252
  },
253
  });
 
233
  return r;
234
  }
235
 
236
+ function describeError(err) {
237
+ if (err == null) return '';
238
+ if (typeof err === 'string') return err;
239
+ if (typeof err === 'number' || typeof err === 'boolean') return String(err);
240
+ if (err instanceof Error) return err.message || String(err);
241
+ if (typeof err === 'object') {
242
+ const parts = [];
243
+ if (typeof err.name === 'string' && err.name) parts.push(err.name);
244
+ if (typeof err.type === 'string' && err.type) parts.push(`type=${err.type}`);
245
+ if (typeof err.message === 'string' && err.message) parts.push(err.message);
246
+ if (typeof err.reason === 'string' && err.reason) parts.push(`reason=${err.reason}`);
247
+ if (typeof err.filename === 'string' && err.filename) parts.push(`file=${err.filename}`);
248
+ if (typeof err.lineno === 'number' && err.lineno > 0) parts.push(`line=${err.lineno}`);
249
+ if (typeof err.colno === 'number' && err.colno > 0) parts.push(`col=${err.colno}`);
250
+ if (typeof err.error === 'string' && err.error) parts.push(`error=${err.error}`);
251
+ else if (err.error instanceof Error && err.error.message) parts.push(`error=${err.error.message}`);
252
+ if (parts.length > 0) return parts.join(' | ');
253
+ try {
254
+ const own = {};
255
+ for (const key of Object.getOwnPropertyNames(err)) {
256
+ own[key] = err[key];
257
+ }
258
+ const json = JSON.stringify(own);
259
+ if (json && json !== '{}') return json;
260
+ } catch {
261
+ // fall through
262
+ }
263
+ const tag = Object.prototype.toString.call(err);
264
+ if (tag && tag !== '[object Object]') return tag;
265
+ return 'unknown structured error';
266
+ }
267
+ return String(err);
268
+ }
269
+
270
  self.onmessage = async (e) => {
271
  const { type } = e.data || {};
272
  if (type !== 'run') {
 
281
  type: 'result',
282
  record: {
283
  status: 'error',
284
+ error: describeError(err),
285
  metrics: null,
286
  },
287
  });
js/run/controller.js CHANGED
@@ -1492,7 +1492,7 @@ function runInWorker({
1492
  worker.onerror = (err) => {
1493
  finish({
1494
  status: 'error',
1495
- error: err?.message || 'worker error (tab likely out of memory)',
1496
  });
1497
  };
1498
  worker.onmessageerror = () => {
@@ -1703,14 +1703,30 @@ function describeError(err) {
1703
  if (typeof err === 'number' || typeof err === 'boolean') return String(err);
1704
  if (err instanceof Error) return err.message || String(err);
1705
  if (typeof err === 'object') {
1706
- if (typeof err.message === 'string' && err.message) return err.message;
1707
- if (typeof err.error === 'string' && err.error) return err.error;
1708
- if (typeof err.reason === 'string' && err.reason) return err.reason;
 
 
 
 
 
 
 
 
1709
  try {
1710
- return JSON.stringify(err);
 
 
 
 
 
1711
  } catch {
1712
- return String(err);
1713
  }
 
 
 
1714
  }
1715
  return String(err);
1716
  }
 
1492
  worker.onerror = (err) => {
1493
  finish({
1494
  status: 'error',
1495
+ error: describeError(err) || 'worker error (tab likely out of memory)',
1496
  });
1497
  };
1498
  worker.onmessageerror = () => {
 
1703
  if (typeof err === 'number' || typeof err === 'boolean') return String(err);
1704
  if (err instanceof Error) return err.message || String(err);
1705
  if (typeof err === 'object') {
1706
+ const parts = [];
1707
+ if (typeof err.name === 'string' && err.name) parts.push(err.name);
1708
+ if (typeof err.type === 'string' && err.type) parts.push(`type=${err.type}`);
1709
+ if (typeof err.message === 'string' && err.message) parts.push(err.message);
1710
+ if (typeof err.reason === 'string' && err.reason) parts.push(`reason=${err.reason}`);
1711
+ if (typeof err.filename === 'string' && err.filename) parts.push(`file=${err.filename}`);
1712
+ if (typeof err.lineno === 'number' && err.lineno > 0) parts.push(`line=${err.lineno}`);
1713
+ if (typeof err.colno === 'number' && err.colno > 0) parts.push(`col=${err.colno}`);
1714
+ if (typeof err.error === 'string' && err.error) parts.push(`error=${err.error}`);
1715
+ else if (err.error instanceof Error && err.error.message) parts.push(`error=${err.error.message}`);
1716
+ if (parts.length > 0) return parts.join(' | ');
1717
  try {
1718
+ const own = {};
1719
+ for (const key of Object.getOwnPropertyNames(err)) {
1720
+ own[key] = err[key];
1721
+ }
1722
+ const json = JSON.stringify(own);
1723
+ if (json && json !== '{}') return json;
1724
  } catch {
1725
+ // fall through
1726
  }
1727
+ const tag = Object.prototype.toString.call(err);
1728
+ if (tag && tag !== '[object Object]') return tag;
1729
+ return 'unknown structured error';
1730
  }
1731
  return String(err);
1732
  }