@lvce-editor/test-with-playwright-worker 22.36.1 → 22.36.2

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.
@@ -460,6 +460,9 @@ const restoreExistingError = (error, currentStack) => {
460
460
  };
461
461
  const restoreMethodNotFoundError = (error, currentStack) => {
462
462
  const restoredError = new JsonRpcError(error.message);
463
+ Object.assign(restoredError, {
464
+ code: error.code
465
+ });
463
466
  const parentStack = getParentStack(error);
464
467
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
465
468
  return restoredError;
@@ -479,9 +482,13 @@ const applyDataProperties = (restoredError, error) => {
479
482
  // @ts-ignore
480
483
  restoredError.codeFrame = error.data.codeFrame;
481
484
  }
482
- if (error.data.code) {
485
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
483
486
  // @ts-ignore
484
- restoredError.code = error.data.code;
487
+ Object.defineProperty(restoredError, 'code', {
488
+ configurable: true,
489
+ value: error.data.code,
490
+ writable: true
491
+ });
485
492
  }
486
493
  if (error.data.type) {
487
494
  // @ts-ignore
@@ -503,6 +510,13 @@ const applyDirectProperties = (restoredError, error) => {
503
510
  };
504
511
  const restoreMessageError = (error, _currentStack) => {
505
512
  const restoredError = constructError(error.message, error.type, error.name);
513
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
514
+ Object.defineProperty(restoredError, 'code', {
515
+ configurable: true,
516
+ value: error.code,
517
+ writable: true
518
+ });
519
+ }
506
520
  if (error.data) {
507
521
  applyDataProperties(restoredError, error);
508
522
  } else {
@@ -581,7 +595,7 @@ const getErrorProperty = (error, prettyError) => {
581
595
  return {
582
596
  code: Custom,
583
597
  data: {
584
- code: prettyError.code,
598
+ code: prettyError.code ?? error?.code,
585
599
  codeFrame: prettyError.codeFrame,
586
600
  name: prettyError.name,
587
601
  stack: getStack(prettyError),
@@ -618,7 +632,12 @@ const getErrorResponseSimple = (id, error) => {
618
632
  return {
619
633
  error: {
620
634
  code: Custom,
621
- data: error,
635
+ data: error instanceof Error ? {
636
+ ...error,
637
+ code: 'code' in error ? error.code : undefined,
638
+ stack: error.stack,
639
+ type: error.name
640
+ } : error,
622
641
  // @ts-ignore
623
642
  message: error.message
624
643
  },
@@ -721,6 +721,9 @@ const restoreExistingError = (error, currentStack) => {
721
721
  };
722
722
  const restoreMethodNotFoundError = (error, currentStack) => {
723
723
  const restoredError = new JsonRpcError(error.message);
724
+ Object.assign(restoredError, {
725
+ code: error.code
726
+ });
724
727
  const parentStack = getParentStack(error);
725
728
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
726
729
  return restoredError;
@@ -740,9 +743,13 @@ const applyDataProperties = (restoredError, error) => {
740
743
  // @ts-ignore
741
744
  restoredError.codeFrame = error.data.codeFrame;
742
745
  }
743
- if (error.data.code) {
746
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
744
747
  // @ts-ignore
745
- restoredError.code = error.data.code;
748
+ Object.defineProperty(restoredError, 'code', {
749
+ configurable: true,
750
+ value: error.data.code,
751
+ writable: true
752
+ });
746
753
  }
747
754
  if (error.data.type) {
748
755
  // @ts-ignore
@@ -764,6 +771,13 @@ const applyDirectProperties = (restoredError, error) => {
764
771
  };
765
772
  const restoreMessageError = (error, _currentStack) => {
766
773
  const restoredError = constructError(error.message, error.type, error.name);
774
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
775
+ Object.defineProperty(restoredError, 'code', {
776
+ configurable: true,
777
+ value: error.code,
778
+ writable: true
779
+ });
780
+ }
767
781
  if (error.data) {
768
782
  applyDataProperties(restoredError, error);
769
783
  } else {
@@ -842,7 +856,7 @@ const getErrorProperty = (error, prettyError) => {
842
856
  return {
843
857
  code: Custom,
844
858
  data: {
845
- code: prettyError.code,
859
+ code: prettyError.code ?? error?.code,
846
860
  codeFrame: prettyError.codeFrame,
847
861
  name: prettyError.name,
848
862
  stack: getStack(prettyError),
@@ -879,7 +893,12 @@ const getErrorResponseSimple = (id, error) => {
879
893
  return {
880
894
  error: {
881
895
  code: Custom,
882
- data: error,
896
+ data: error instanceof Error ? {
897
+ ...error,
898
+ code: 'code' in error ? error.code : undefined,
899
+ stack: error.stack,
900
+ type: error.name
901
+ } : error,
883
902
  // @ts-ignore
884
903
  message: error.message
885
904
  },
@@ -2210,10 +2229,14 @@ const getElectronLaunchOptions = ({
2210
2229
  args,
2211
2230
  env,
2212
2231
  executablePath
2213
- }) => {
2232
+ }, profileRoot) => {
2214
2233
  const launchEnv = {
2215
2234
  ...getProcessEnv(),
2216
- ...env
2235
+ ...env,
2236
+ XDG_CACHE_HOME: join(profileRoot, 'cache'),
2237
+ XDG_CONFIG_HOME: join(profileRoot, 'config'),
2238
+ XDG_DATA_HOME: join(profileRoot, 'data'),
2239
+ XDG_STATE_HOME: join(profileRoot, 'state')
2217
2240
  };
2218
2241
  delete launchEnv['ELECTRON_RUN_AS_NODE'];
2219
2242
  return {
@@ -2252,19 +2275,19 @@ const createElectronLaunch = ({
2252
2275
  signal,
2253
2276
  userDataDir
2254
2277
  }) => {
2255
- let disposed = false;
2256
- const dispose = async () => {
2257
- if (disposed) {
2258
- return;
2278
+ let disposal;
2279
+ const dispose = () => {
2280
+ if (disposal) {
2281
+ return disposal;
2259
2282
  }
2260
- disposed = true;
2261
2283
  signal.removeEventListener('abort', handleAbort);
2262
2284
  process.off('SIGINT', handleSigint);
2263
2285
  process.off('SIGTERM', handleSigterm);
2264
- await closeElectron({
2286
+ disposal = closeElectron({
2265
2287
  electronApp,
2266
2288
  userDataDir
2267
2289
  });
2290
+ return disposal;
2268
2291
  };
2269
2292
  const handleAbort = () => {
2270
2293
  void dispose();
@@ -2297,14 +2320,15 @@ const startElectron = async ({
2297
2320
  runtimeOptions,
2298
2321
  signal
2299
2322
  }) => {
2300
- const launchOptions = getElectronLaunchOptions(runtimeOptions);
2301
2323
  const userDataDir = await mkdtemp(join(tmpdir(), 'test-with-playwright-electron-'));
2302
- const args = getElectronProcessArgs({
2303
- args: launchOptions.args,
2304
- userDataDir
2305
- });
2306
2324
  let electronApp;
2307
2325
  try {
2326
+ signal.throwIfAborted();
2327
+ const launchOptions = getElectronLaunchOptions(runtimeOptions, userDataDir);
2328
+ const args = getElectronProcessArgs({
2329
+ args: launchOptions.args,
2330
+ userDataDir
2331
+ });
2308
2332
  const {
2309
2333
  _electron
2310
2334
  } = await import('@playwright/test');
@@ -2314,9 +2338,11 @@ const startElectron = async ({
2314
2338
  executablePath: launchOptions.executablePath,
2315
2339
  timeout: electronLaunchTimeout
2316
2340
  });
2341
+ signal.throwIfAborted();
2317
2342
  const page = await electronApp.firstWindow({
2318
2343
  timeout: electronLaunchTimeout
2319
2344
  });
2345
+ signal.throwIfAborted();
2320
2346
  return createElectronLaunch({
2321
2347
  electronApp,
2322
2348
  page,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright-worker",
3
- "version": "22.36.1",
3
+ "version": "22.36.2",
4
4
  "description": "Worker package for test-with-playwright",
5
5
  "repository": {
6
6
  "type": "git",