All jobs / Frontend / web developer
Frontend / web developer interview question · 5+ years
A trader UI keeps the whole order book in a WebSocket reducer. A blip shows an empty book.
What is the socket allowed to be?
The strongest answer
A hint to refetch or a delta on top of a REST/GraphQL snapshot — if the socket drops, the UI can still rebuild state from HTTP
Why it works
Exactly. Sockets die. Mobile radios die. The snapshot is the source of truth; the socket is freshness. Otherwise every reconnect is a product bug.
What a good answer covers
- HTTP (or a query) can rebuild the world.
- The socket pushes invalidations or deltas.
- Reconnect = snapshot, then resume.
- Do not hide authz in a message handler only.
Answers that fall short
- Close, but not the strongest: The only store; HTTP is just for login
A socket-only store is a state machine you will not replay after a load balancer blip. - Weak: A backup channel we ignore until HTTP fails
Ignoring the socket until failure means you paid for a protocol you do not use. - Red flag: A place to run authorisation we skipped on the API
Authz that exists only on a message type is authz a forged client will skip — and your HTTP POST will too.
Who gets asked this
More Frontend / web developer questions
- A setInterval inside useEffect always logs the initial count. Why?
- A member must not see 'Transfer ownership'. An admin must. What do you implement?
- When is useMemo worth it?
- Why wrap a handler in useCallback?
- The team argues whether a field is `userId` or `user_id`. What is OpenAPI for here?
- When does React.memo help, and when does it not?
- The register API can fail because the email is taken or because the password is too short. What should the UI…
- The app feels sluggish when typing in one field. How do you find the cause?