hcengineering/platform · error · Error
Sign in is not initialized
Error message
Sign in is not initialized
What it means
authCode() looks up the connection for the phone and requires an active signInFlow; if the flow was never started (init not called) or already finished/cleared, there is nothing to submit the code to, so it throws.
Source
Thrown at services/telegram/pod-telegram/src/telegram.ts:363
}
try {
await conn.signIn()
} catch (err) {
this.forgetConnection(phone)
await conn.close()
throw err
}
return 'code'
}
async authCode (phone: string, code: string): Promise<boolean> {
const conn = this.conns.get(phone)
if (conn?.signInFlow === undefined) {
throw Error('Sign in is not initialized')
}
return await conn.signInFlow.code(code)
}
async authPass (phone: string, pass: string): Promise<void> {
const conn = this.conns.get(phone)
if (conn?.signInFlow === undefined) {
throw Error('Sign in is not initialized')
}
await conn.signInFlow.pass(pass)
}
async getOrCreate (phone: string): Promise<TelegramConnection> {
const existingConn = this.conns.get(phone)
View on GitHub (pinned to 63e28dc964)
Solutions
- Call the sign-in init (send code) step before authCode for the same phone
- Restart the sign-in flow (send a new code) when this error is caught
- Persist or re-check flow state so reconnects don't silently drop the pending flow
- Disable the code submission form until the flow is confirmed active
Example fix
// before
const ok = await service.authCode(phone, code) // throws if flow gone
// after
try {
await service.authCode(phone, code)
} catch (err) {
if (err.message === 'Sign in is not initialized') {
await service.requestCode(phone) // restart flow
}
} Defensive patterns
Strategy: try-catch
Validate before calling
const conn = service.getConnection(phone) if (conn?.signInFlow === undefined) await service.requestCode(phone) // initialize first
Type guard
const canSubmit = (conn: { signInFlow?: SignInFlow } | undefined): conn is { signInFlow: SignInFlow } =>
conn?.signInFlow !== undefined Try / catch
try {
await service.authCode(phone, code)
} catch (err) {
if (err.message === 'Sign in is not initialized') {
await service.requestCode(phone)
}
} Prevention
- Always complete the send-code step before collecting the code
- Re-initialize the flow after reconnects or service restarts
- Expire the code entry UI when the flow is dropped
When it happens
Trigger: authCode(phone, code) called without a prior auth flow initialization for that phone, after sign-in completed, or when conns.get(phone) returns no connection at all.
Common situations: Session expired or reconnect replaced the connection while the user was typing the code; calling authCode from a stale UI screen; restarting the service mid-sign-in loses flow state.
Related errors
- User is not signed in
- Invalid workspace: '${user.workspace}'
- Invalid sign in method
- Account does not exist
- Token revoked
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/fcde9bbb79e20a36.
Report an issue: GitHub.