fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1748 from Matsuuu/openapi-ts-watch-mode-crash

authored by

Lubos and committed by
GitHub
9cbbc619 c319ba3b

+21 -8
+5
.changeset/shy-mugs-rescue.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + fix: Wrap HEAD request in a try-catch to prevent watch mode crashes on server reloads
+16 -8
packages/openapi-ts/src/getSpec.ts
··· 40 40 if (resolvedInput.type === 'url') { 41 41 // do NOT send HEAD request on first run or if unsupported 42 42 if (watch.lastValue && watch.isHeadMethodSupported !== false) { 43 - const request = await sendRequest({ 44 - init: { 45 - headers: watch.headers, 46 - method: 'HEAD', 47 - }, 48 - timeout, 49 - url: resolvedInput.path, 50 - }); 43 + let request; 44 + try { 45 + request = await sendRequest({ 46 + init: { 47 + headers: watch.headers, 48 + method: 'HEAD', 49 + }, 50 + timeout, 51 + url: resolvedInput.path, 52 + }); 53 + } catch (ex) { 54 + return { 55 + error: 'not-ok', 56 + response: new Response(ex.message), 57 + }; 58 + } 51 59 response = request.response; 52 60 53 61 if (!response.ok && watch.isHeadMethodSupported) {