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) { if (nitroInitResult?.error) {
events.emit(ModelEvent.OnModelFail, model) events.emit(ModelEvent.OnModelFail, {
...model,
error: nitroInitResult.error,
})
return return
} }

View File

@ -310,9 +310,15 @@ async function killSubprocess(): Promise<void> {
subprocess?.kill() subprocess?.kill()
subprocess = undefined subprocess = undefined
}) })
.catch(() => {}) .catch(() => {}) // Do nothing with this attempt
.then(() => tcpPortUsed.waitUntilFree(PORT, 300, 5000)) .then(() => tcpPortUsed.waitUntilFree(PORT, 300, 5000))
.then(() => log(`[NITRO]::Debug: Nitro process is terminated`)) .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( const onModelInitFailed = useCallback(
(res: any) => { (res: any) => {
const errorMessage = `${res.error}` const errorMessage = res?.error ?? res
console.error('Failed to load model: ' + errorMessage) console.error('Failed to load model: ', errorMessage)
setStateModel(() => ({ setStateModel(() => ({
state: 'start', state: 'start',
loading: false, loading: false,

View File

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