Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

useTracker problem - Can't set timers inside simulations

Open
#396 18 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
frontend

Research direction

Reproduce the transition from a null to non-null contact, then inspect the useTracker.ts paths at lines 81 and 163 shown in the stack traces, including useTrackerClient and useTrackerDev. Done means the transition no longer raises "Can't set timers inside simulations" and the tracker can proceed through the reported subscription scenario.

Written by the indexing model from the issue text.

Description

bug

I'm using useTracker like this:

<div>{!contact ? null : (
  <AsyncValue
    subscription={{
      name: 'mail.contactStats',
      args: [contact.ID],
      query: () => MailStats.findOne({ _id: `for-contact-${contact.ID}` }),
    }}
  />
)}</div
export function AsyncValue({ promise, subscription, render, children, onError }) {
  const [error, setError] = useState(null);
  const { name, args, query } = subscription;
  const value = useTracker(
    () => {
      LOG('METEOR TRACKER?', subscription);
      if (error) return undefined; // otherwise we get an infinite loop trying to resubscribe
      
      // I COMMENTED MY WHOLE CODE TO NARROW DOWN THE PROBLEM, IT STILL APPEARS
      // const sub = Meteor.subscribe(name, ...args, {
      //   onStop: error => {
      //     if (onError) {
      //       DEBUG(`AsyncValue subscription error, sending to onError:`, error);
      //       onError(error, setError);
      //     } else {
      //       if (error) console.error('AsyncValue Subscription error:', error);
      //       setError(error);
      //     }
      //   },
      // });
      // DEBUG(`sub: ready=${sub.ready()}, entries:`, query);
      // return sub.ready() ? query() : undefined;
      return undefined;
    }
    []
  );
  DEBUG(`sub value:`, value);

  const renderValue = () => (render ? render(value) : value);
  return <>{value !== undefined ? renderValue() : placeholder()}</>;
}

Works fine if contact is set from the start - but whenever contact changes from being null to non-null, this error occurs:

Uncaught Error: Can't set timers inside simulations
    at withoutInvocation (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:621:13)
    at bindAndCatch (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:633:33)
    at Meteor.defer (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:694:24)
    at useTracker.ts:163:12
    at mountMemo (modules.js?hash=bfdeb58d2ee948751f18b6466ad43663c2847a1e:133794:19)
    at Object.useMemo (modules.js?hash=bfdeb58d2ee948751f18b6466ad43663c2847a1e:134090:16)
    at useMemo (modules.js?hash=bfdeb58d2ee948751f18b6466ad43663c2847a1e:113407:21)
    at useTrackerWithDeps (useTracker.ts:137:3)
    at useTrackerClient (useTracker.ts:206:12)
    at useTrackerDev (useTracker.ts:244:16)

Also tried useTracker with subscription as dep (same error as above) and without deps - which causes this error:

Uncaught Error: Can't set timers inside simulations
    at withoutInvocation (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:621:13)
    at bindAndCatch (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:633:33)
    at Meteor.defer (meteor.js?hash=3fe70c93a2fcd225dc5cc6572b8c3e39756a507b:694:24)
    at useTrackerNoDeps (useTracker.ts:81:12)
    at useTrackerClient (useTracker.ts:204:12)
    at useTrackerDev (useTracker.ts:244:16)
Dominant language
JavaScript
Stars
576
Forks
167
Avg merge
4d 3h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from meteor/react-packages

All issues in meteor/react-packages

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.