Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion extensions/inference-nitro-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 7 additions & 1 deletion extensions/inference-nitro-extension/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
})
}

/**
Expand Down
4 changes: 2 additions & 2 deletions web/containers/Providers/EventHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
64 changes: 45 additions & 19 deletions web/screens/Chat/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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>
Expand All @@ -41,25 +44,48 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
</div>
)}
{message.status === MessageStatus.Error && (
<div
key={message.id}
className="flex flex-col items-center text-center text-sm font-medium text-gray-500"
>
<p>{`Apologies, something’s amiss!`}</p>
<p>
Jan’s in beta. Access&nbsp;
<span
className="cursor-pointer text-primary dark:text-blue-400"
onClick={() => setModalTroubleShooting(true)}
<>
{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"
>
troubleshooting assistance
</span>
&nbsp;now.
</p>
<ModalTroubleShooting />
</div>
<p className="w-[90%]">
Failed to use a port, causing a fatal error. Check for
conflicting apps and ensure the port is available, 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"
>
<p>{`Apologies, something’s amiss!`}</p>
<p>
Jan’s 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
Loading