Skip to content

[BUG] Realtime refuses to connect if instantiated with enabled: false #1146

@Thinkscape

Description

@Thinkscape

Describe the bug

When the hook is initially disabled, it will never re-connect if enabled flips to true.

To Reproduce

const [useRealtime, setUseRealtime] = useState(false);
const { latestData, state: realtimeState } = useInngestSubscription({
    refreshToken: tokenFn,
    enabled: useRealtime,
  });

// Enable after delay
useLayoutEffect(() => {
  setTimeout(() => setUseRealtimeEffect(true), 2000);
});

console.log({ useRealtime, state });

Expected behavior

useRealtime: false, state: closed
useRealtime: true, state: connecting
useRealtime: true, state: active

Actual behavior

useRealtime: false, state: closed
useRealtime: true, state: closed

Code snippets / Logs / Screenshots

Image

System info (please complete the following information):

  • OS: linux
  • npm package Version: 0.4.4
  • Framework: next.js 15/react
  • Platform: vercel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions