fix: failed to bind port - nitro error message copy (#2101)

* fix: failed to bind port - nitro error message copy

* fix: copy
This commit is contained in:
Louis 2024-02-20 13:54:21 +07:00 committed by GitHub
parent 6b88d4df4d
commit 7fbc6cb6c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 57 additions and 23 deletions

View File

@ -154,7 +154,10 @@ export default class JanInferenceNitroExtension extends InferenceExtension {
})
if (nitroInitResult?.error) {
events.emit(ModelEvent.OnModelFail, model)
events.emit(ModelEvent.OnModelFail, {
...model,
error: nitroInitResult.error,
})
return
}

View File

@ -310,9 +310,15 @@ async function killSubprocess(): Promise<void> {
subprocess?.kill()
subprocess = undefined
})
.catch(() => {})
.catch(() => {}) // Do nothing with this attempt
.then(() => tcpPortUsed.waitUntilFree(PORT, 300, 5000))
.then(() => log(`[NITRO]::Debug: Nitro process is terminated`))
.catch((err) => {
log(
`[NITRO]::Debug: Could not kill running process on port ${PORT}. Might be another process running on the same port? ${err}`
)
throw 'PORT_NOT_AVAILABLE'
})
}
/**

View File

@ -114,8 +114,8 @@ export default function EventHandler({ children }: { children: ReactNode }) {
const onModelInitFailed = useCallback(
(res: any) => {
const errorMessage = `${res.error}`
console.error('Failed to load model: ' + errorMessage)
const errorMessage = res?.error ?? res
console.error('Failed to load model: ', errorMessage)
setStateModel(() => ({
state: 'start',
loading: false,

View File

@ -7,6 +7,7 @@ import ModalTroubleShooting, {
modalTroubleShootingAtom,
} from '@/containers/ModalTroubleShoot'
import { loadModelErrorAtom } from '@/hooks/useActiveModel'
import useSendChatMessage from '@/hooks/useSendChatMessage'
import { getCurrentChatMessagesAtom } from '@/helpers/atoms/ChatMessage.atom'
@ -15,6 +16,8 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
const messages = useAtomValue(getCurrentChatMessagesAtom)
const { resendChatMessage } = useSendChatMessage()
const setModalTroubleShooting = useSetAtom(modalTroubleShootingAtom)
const loadModelError = useAtomValue(loadModelErrorAtom)
const PORT_NOT_AVAILABLE = 'PORT_NOT_AVAILABLE'
const regenerateMessage = async () => {
const lastMessageIndex = messages.length - 1
@ -23,9 +26,9 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
}
return (
<>
<div className="mt-10">
{message.status === MessageStatus.Stopped && (
<div key={message.id} className="mt-10 flex flex-col items-center">
<div key={message.id} className="flex flex-col items-center">
<span className="mb-3 text-center text-sm font-medium text-gray-500">
Oops! The generation was interrupted. Let&apos;s give it another go!
</span>
@ -41,6 +44,26 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
</div>
)}
{message.status === MessageStatus.Error && (
<>
{loadModelError === PORT_NOT_AVAILABLE ? (
<div
key={message.id}
className="flex flex-col items-center text-center text-sm font-medium text-gray-500 w-full"
>
<p className="w-[90%]">
Port 3928 is currently unavailable. Check for conflicting apps,
or access&nbsp;
<span
className="cursor-pointer text-primary dark:text-blue-400"
onClick={() => setModalTroubleShooting(true)}
>
troubleshooting assistance
</span>
&nbsp;for further support.
</p>
<ModalTroubleShooting />
</div>
) : (
<div
key={message.id}
className="flex flex-col items-center text-center text-sm font-medium text-gray-500"
@ -60,6 +83,8 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
</div>
)}
</>
)}
</div>
)
}
export default ErrorMessage