meteor / meteor/react-packages
useTracker problem - Can't set timers inside simulations
- Dominant language
- JavaScript
- Stars
- 575
- Forks
- 168
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 1
Description
I'm using `useTracker` like this:
```jsx
MailStats.findOne({ _id: `for-contact-${contact.ID}` }),
}}
/>
)}
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)
```
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100