openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

I'm loading a couple pieces like this in my frontend, mostly to use `.fromReadableStream`. It works when in dev mode (nextjs) but when I build I get an error about `Audio` already being declared in the app console. I'm not using anything with "audio" so I'm going to guess it's the way I'm loading them that's either causing it to load twice or there's something else going on.

Open a2thek26 opened this issue 2 years ago • 2 comments

I'm loading a couple pieces like this in my frontend, mostly to use .fromReadableStream. It works when in dev mode (nextjs) but when I build I get an error about Audio already being declared in the app console. I'm not using anything with "audio" so I'm going to guess it's the way I'm loading them that's either causing it to load twice or there's something else going on.

import { APIUserAbortError } from 'openai';
import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream';

I'm loading the abort error to handle when the stream gets aborted.

Originally posted by @a2thek26 in https://github.com/openai/openai-node/discussions/182#discussioncomment-7742034

a2thek26 avatar Dec 05 '23 02:12 a2thek26

Thanks.

As a workaround, can you try importing the error class directly from the file it's declared in, or just checking error.name === 'APIUserAbortError'?

rattrayalex avatar Dec 05 '23 04:12 rattrayalex

cc @kenjam97 who reported:

Also seeing this same error when I build (nextjs), no issues in dev mode at all, only in production

Could you try either workaround?

rattrayalex avatar Dec 08 '23 04:12 rattrayalex