#Your worker created multiple branches of a single stream (for instance, by calling response.clone()

1 messages · Page 1 of 1 (latest)

potent perch
weary swift
#

Seems like a valid warning - it clones but only tries to read the second branch in the event of an error.

potent perch
#

@weary swift it throws the warning even though I commented the cloning part out:

export async function safeParseJSON<T>(
    input: string | ResponseEsque | RequestLike,
): Promise<T | Error> {
    if (typeof input === "string") {
        try {
            return JSON.parse(input) as T;
        } catch (err) {
            console.error(`Error parsing JSON, got '${input}'`);
            return new Error(`Error parsing JSON, got '${input}'`);
        }
    }

    //const clonedRes = input.clone?.();
    try {
        return (await input.json()) as T;
    } catch (err) {
        //const text = (await input?.text()) ?? "unknown";
        //const text = await input?.text()) ?? "unknown";
        //console.error(`Error parsing JSON, got '${text}'`);
        return new Error(`Error parsing JSON, got '${input}'`);
    }
}
weary swift
#

Look for other usages of clone