Skip to content

Commit 40b796b

Browse files
committed
Revert "Replace c8 ignore comments with v8 ignore for vitest compatibility"
This reverts commit 1f8fe70.
1 parent 1f8fe70 commit 40b796b

7 files changed

Lines changed: 64 additions & 64 deletions

File tree

src/file-upload.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function createUploadRequest(
8989
const requestBody = [
9090
...requestBodyNoBoundaries.flatMap(part => [
9191
boundarySep,
92-
/* v8 ignore next - Array.isArray branch for part is defensive coding for edge cases. */
92+
/* c8 ignore next - Array.isArray branch for part is defensive coding for edge cases. */
9393
...(Array.isArray(part) ? part : [part]),
9494
]),
9595
finalBoundary,
@@ -117,12 +117,12 @@ export async function createUploadRequest(
117117

118118
try {
119119
for (const part of requestBody) {
120-
/* v8 ignore next 3 - aborted state is difficult to test reliably */
120+
/* c8 ignore next 3 - aborted state is difficult to test reliably */
121121
if (aborted) {
122122
break
123123
}
124124
if (typeof part === 'string') {
125-
/* v8 ignore next 5 - backpressure handling requires specific stream conditions */
125+
/* c8 ignore next 5 - backpressure handling requires specific stream conditions */
126126
if (!req.write(part)) {
127127
// Wait for 'drain' if backpressure is signaled.
128128
// eslint-disable-next-line no-await-in-loop
@@ -133,17 +133,17 @@ export async function createUploadRequest(
133133
const stream = part as Readable
134134
// eslint-disable-next-line no-await-in-loop
135135
for await (const chunk of stream) {
136-
/* v8 ignore next 3 - aborted state during streaming is difficult to test reliably */
136+
/* c8 ignore next 3 - aborted state during streaming is difficult to test reliably */
137137
if (aborted) {
138138
break
139139
}
140-
/* v8 ignore next 3 - backpressure handling requires specific stream conditions */
140+
/* c8 ignore next 3 - backpressure handling requires specific stream conditions */
141141
if (!req.write(chunk)) {
142142
await events.once(req, 'drain')
143143
}
144144
}
145145
// Ensure trailing CRLF after file part.
146-
/* v8 ignore next 4 - trailing CRLF backpressure handling is edge case */
146+
/* c8 ignore next 4 - trailing CRLF backpressure handling is edge case */
147147
if (!aborted && !req.write('\r\n')) {
148148
// eslint-disable-next-line no-await-in-loop
149149
await events.once(req, 'drain')
@@ -152,7 +152,7 @@ export async function createUploadRequest(
152152
if (typeof part.destroy === 'function') {
153153
part.destroy()
154154
}
155-
/* v8 ignore next 3 - defensive check for non-string/stream types */
155+
/* c8 ignore next 3 - defensive check for non-string/stream types */
156156
} else {
157157
throw new TypeError('Expected "string" or "stream" type')
158158
}

src/http-client.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ export class ResponseError extends Error {
2929
* Automatically formats error message with status code and message.
3030
*/
3131
constructor(response: IncomingMessage, message = '') {
32-
/* v8 ignore next 2 - statusCode and statusMessage may be undefined in edge cases */
32+
/* c8 ignore next 2 - statusCode and statusMessage may be undefined in edge cases */
3333
const statusCode = response.statusCode ?? 'unknown'
3434
const statusMessage = response.statusMessage ?? 'No status message'
3535
super(
36-
/* v8 ignore next - fallback empty message if not provided */
36+
/* c8 ignore next - fallback empty message if not provided */
3737
`Socket API ${message || 'Request failed'} (${statusCode}): ${statusMessage}`,
3838
)
3939
this.name = 'ResponseError'
@@ -126,7 +126,7 @@ export async function getErrorResponseBody(
126126
response.setEncoding('utf8')
127127
response.on('data', (chunk: string) => (body += chunk))
128128
response.on('end', () => resolve(body))
129-
/* v8 ignore next - Extremely rare network or stream error during error response reading. */
129+
/* c8 ignore next - Extremely rare network or stream error during error response reading. */
130130
response.on('error', e => reject(e))
131131
})
132132
}
@@ -151,7 +151,7 @@ export async function getResponse(
151151
return await new Promise((resolve, reject) => {
152152
let timedOut = false
153153
req.on('response', (response: IncomingMessage) => {
154-
/* v8 ignore next 3 - Race condition where response arrives after timeout. */
154+
/* c8 ignore next 3 - Race condition where response arrives after timeout. */
155155
if (timedOut) {
156156
return
157157
}
@@ -162,13 +162,13 @@ export async function getResponse(
162162
req.destroy()
163163
reject(new Error('Request timed out'))
164164
})
165-
/* v8 ignore start - Network error handling during request, difficult to test reliably. */
165+
/* c8 ignore start - Network error handling during request, difficult to test reliably. */
166166
req.on('error', e => {
167167
if (!timedOut) {
168168
reject(e)
169169
}
170170
})
171-
/* v8 ignore stop */
171+
/* c8 ignore stop */
172172
})
173173
}
174174

@@ -215,7 +215,7 @@ export async function getResponseJson(
215215
Object.setPrototypeOf(enhancedError, SyntaxError.prototype)
216216
throw enhancedError
217217
}
218-
/* v8 ignore start - Error instanceof check and unknown error handling for JSON parsing edge cases. */
218+
/* c8 ignore start - Error instanceof check and unknown error handling for JSON parsing edge cases. */
219219
if (e instanceof Error) {
220220
throw e
221221
}
@@ -229,7 +229,7 @@ export async function getResponseJson(
229229
unknownError.originalResponse = responseBody
230230
Object.setPrototypeOf(unknownError, SyntaxError.prototype)
231231
throw unknownError
232-
/* v8 ignore stop */
232+
/* c8 ignore stop */
233233
}
234234
}
235235

@@ -239,7 +239,7 @@ export async function getResponseJson(
239239
*/
240240
export function isResponseOk(response: IncomingMessage): boolean {
241241
const { statusCode } = response
242-
/* v8 ignore next - Defensive fallback for edge cases where statusCode might be undefined. */
242+
/* c8 ignore next - Defensive fallback for edge cases where statusCode might be undefined. */
243243
return statusCode ? statusCode >= 200 && statusCode < 300 : false
244244
}
245245

@@ -250,7 +250,7 @@ export function isResponseOk(response: IncomingMessage): boolean {
250250
export function reshapeArtifactForPublicPolicy<
251251
T extends Record<string, unknown>,
252252
>(data: T, isAuthenticated: boolean, actions?: string | undefined): T {
253-
/* v8 ignore start - Public policy artifact reshaping for unauthenticated users, difficult to test edge cases. */
253+
/* c8 ignore start - Public policy artifact reshaping for unauthenticated users, difficult to test edge cases. */
254254
// If user is not authenticated, provide a different response structure
255255
// optimized for the public free-tier experience.
256256
if (!isAuthenticated) {
@@ -310,7 +310,7 @@ export function reshapeArtifactForPublicPolicy<
310310
}
311311
}
312312
return data
313-
/* v8 ignore stop */
313+
/* c8 ignore stop */
314314
}
315315

316316
/**

src/promise-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class PromiseQueue {
5454
}
5555

5656
const task = this.queue.shift()
57-
/* v8 ignore next 3 - Defensive check; unreachable since we verify queue.length above */
57+
/* c8 ignore next 3 - Defensive check; unreachable since we verify queue.length above */
5858
if (!task) {
5959
return
6060
}

0 commit comments

Comments
 (0)