Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setTimeout handler is never invoked #22459

Closed
3 tasks done
haggholm opened this issue Nov 29, 2018 · 3 comments
Closed
3 tasks done

setTimeout handler is never invoked #22459

haggholm opened this issue Nov 29, 2018 · 3 comments
Labels
Bug Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.

Comments

@haggholm
Copy link

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
      CPU: (8) x64 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
      Memory: 367.60 MB / 31.39 GB
      Shell: 4.4.19 - /bin/bash
    Binaries:
      Node: 10.13.0 - /usr/bin/node
      Yarn: 1.5.1 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 23, 24, 26, 27
        Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.2, 28.0.3
        System Images: android-26 | Google APIs Intel x86 Atom
    npmGlobalPackages:
      babel-preset-react-native: 5.0.0
      react-native-git-upgrade: 0.2.7

Description

A piece of our network logic involves a delay to collect WS messages for batch sends. The relevant code looks like this:

if (!currentBatchPromise) {
	logger.debug('Enqueueing new batch promise');
	currentBatchPromise = new Promise((resolve, reject) =>
		setTimeout(() => sendCurrentBatch(resolve, reject), 10)
	);
}

Most of the time, this works fine. However, sometimes the timeout handler (sendCurrentBatch) is never invoked. Typically, this happens when transitioning between different screens, using react-native-navigation (v2); I’m not sure which project this bug should be filed under. I have a vague suspicion that it might be something like #22089 (“Timers do not run if specified before App mounts”), compounded by the fact that (if I understand correctly) RNN, on some level, creates more than one “app”. I do not know the details.

But it seems very…wrong…that a function like setTimeout can somehow stop working in the middle of a running application.

@ex3ndr
Copy link

ex3ndr commented Jan 31, 2019

I have same issue, i am using Headless JS to keep JS VM running after activity closing and on second load no setTimeout works at all.

@ex3ndr
Copy link

ex3ndr commented Feb 1, 2019

I have solved my issue it was a problem with HeadlessJS.
I was starting service in onCreate of Application to keep app alive after destroying, but this essentially kills timers. Starting service in onPause of Activity solves this problem.

@dulmandakh
Copy link
Contributor

Hello there 👋 this issue doesn't have a repro (which means, a react-native init-ed project with the minimal changes that leads to creating the same issue you are reporting). Unfortunately, I have no way of helping you in a meaningful way – there is no easy way for me to recreate the situation and check that the issue reported is still there when changing the code.

Because of this, we are going to close this issue - but if a repro is shared, we are happy to reopen it 🤗

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants