msw 2.11.2 → 2.11.3

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.
@@ -115,17 +115,16 @@ var DEFAULT_START_OPTIONS = {
115
115
  // src/browser/setupWorker/start/createStartHandler.ts
116
116
  import { devUtils as devUtils6 } from '../core/utils/internal/devUtils.mjs';
117
117
 
118
- // node_modules/.pnpm/@open-draft+until@2.1.0/node_modules/@open-draft/until/lib/index.mjs
119
- var until = async (promise) => {
118
+ // node_modules/.pnpm/until-async@3.0.2/node_modules/until-async/lib/index.js
119
+ async function until(callback) {
120
120
  try {
121
- const data = await promise().catch((error2) => {
121
+ return [null, await callback().catch((error2) => {
122
122
  throw error2;
123
- });
124
- return { error: null, data };
123
+ })];
125
124
  } catch (error2) {
126
- return { error: error2, data: null };
125
+ return [error2, null];
127
126
  }
128
- };
127
+ }
129
128
 
130
129
  // src/browser/setupWorker/start/utils/getWorkerInstance.ts
131
130
  import { devUtils } from '../core/utils/internal/devUtils.mjs';
@@ -174,19 +173,17 @@ var getWorkerInstance = async (url, options = {}, findWorker) => {
174
173
  existingRegistration
175
174
  ];
176
175
  }
177
- const registrationResult = await until(
178
- async () => {
179
- const registration = await navigator.serviceWorker.register(url, options);
180
- return [
181
- // Compare existing worker registration by its worker URL,
182
- // to prevent irrelevant workers to resolve here (such as Codesandbox worker).
183
- getWorkerByRegistration(registration, absoluteWorkerUrl, findWorker),
184
- registration
185
- ];
186
- }
187
- );
188
- if (registrationResult.error) {
189
- const isWorkerMissing = registrationResult.error.message.includes("(404)");
176
+ const [registrationError, registrationResult] = await until(async () => {
177
+ const registration = await navigator.serviceWorker.register(url, options);
178
+ return [
179
+ // Compare existing worker registration by its worker URL,
180
+ // to prevent irrelevant workers to resolve here (such as Codesandbox worker).
181
+ getWorkerByRegistration(registration, absoluteWorkerUrl, findWorker),
182
+ registration
183
+ ];
184
+ });
185
+ if (registrationError) {
186
+ const isWorkerMissing = registrationError.message.includes("(404)");
190
187
  if (isWorkerMissing) {
191
188
  const scopeUrl = new URL(options?.scope || "/", location.href);
192
189
  throw new Error(
@@ -200,11 +197,11 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
200
197
  throw new Error(
201
198
  devUtils.formatMessage(
202
199
  "Failed to register the Service Worker:\n\n%s",
203
- registrationResult.error.message
200
+ registrationError.message
204
201
  )
205
202
  );
206
203
  }
207
- return registrationResult.data;
204
+ return registrationResult;
208
205
  };
209
206
 
210
207
  // node_modules/.pnpm/@open-draft+deferred-promise@2.2.0/node_modules/@open-draft/deferred-promise/build/index.mjs
@@ -1628,6 +1625,18 @@ var WorkerChannel = class extends Emitter2 {
1628
1625
  }
1629
1626
  };
1630
1627
 
1628
+ // node_modules/.pnpm/@open-draft+until@2.1.0/node_modules/@open-draft/until/lib/index.mjs
1629
+ var until2 = async (promise) => {
1630
+ try {
1631
+ const data = await promise().catch((error2) => {
1632
+ throw error2;
1633
+ });
1634
+ return { error: null, data };
1635
+ } catch (error2) {
1636
+ return { error: error2, data: null };
1637
+ }
1638
+ };
1639
+
1631
1640
  // node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-L37TY7LC.mjs
1632
1641
  var InterceptorError = class extends Error {
1633
1642
  constructor(message) {
@@ -1790,7 +1799,7 @@ async function handleRequest2(options) {
1790
1799
  );
1791
1800
  }
1792
1801
  }
1793
- const result = await until(async () => {
1802
+ const result = await until2(async () => {
1794
1803
  const requestListenersPromise = emitAsync(options.emitter, "request", {
1795
1804
  requestId: options.requestId,
1796
1805
  request: options.request,
@@ -1826,7 +1835,7 @@ async function handleRequest2(options) {
1826
1835
  unhandledExceptionController[kResponsePromise].resolve(void 0);
1827
1836
  }
1828
1837
  });
1829
- const nextResult = await until(
1838
+ const nextResult = await until2(
1830
1839
  () => unhandledExceptionController[kResponsePromise]
1831
1840
  );
1832
1841
  if (nextResult.error) {