cmd/tsconnect: add error callback for SSH sessions

We were just logging them to the console, which is useful for debugging,
but we may want to show them in the UI too.

Updates tailscale/corp#6939

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
pull/5716/head
Mihai Parparita 2 years ago committed by Mihai Parparita
parent e9b98dd2e1
commit a7a0baf6b9

@ -46,7 +46,7 @@ function SSHSession({
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
if (ref.current) {
runSSHSession(ref.current, def, ipn, onDone)
runSSHSession(ref.current, def, ipn, onDone, (err) => console.error(err))
}
}, [ref])

@ -14,6 +14,7 @@ export function runSSHSession(
def: SSHSessionDef,
ipn: IPN,
onDone: () => void,
onError?: (err: string) => void,
terminalOptions?: ITerminalOptions
) {
const parentWindow = termContainerNode.ownerDocument.defaultView ?? window
@ -48,7 +49,7 @@ export function runSSHSession(
term.write(input)
},
writeErrorFn(err) {
console.error(err)
onError?.(err)
term.write(err)
},
setReadFn(hook) {

Loading…
Cancel
Save