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

Cannot use fetch inside scheduled runner #71

Open
saulojg opened this issue Feb 26, 2024 · 2 comments
Open

Cannot use fetch inside scheduled runner #71

saulojg opened this issue Feb 26, 2024 · 2 comments

Comments

@saulojg
Copy link

saulojg commented Feb 26, 2024

We've created a scheduled runner:

    BackgroundRunner: {
      label: '<not relevant>',
      src: 'runners/runner.js',
      event: 'handleNotifications',
      repeat: true,
      interval: 1,
      autoStart: true,
    }

inside the event handler we try to use fetch as follows:

  fetch("https://jsonplaceholder.typicode.com/todos/1").then((data) => {
    console.log("fetch ok");
    resolve();
  }).catch((err) => {
    console.log("fetch failed");
    console.log(err);
    reject();
  });

Only the catch block gets executed, but the err parameter is always empty.

This was tested with 2 different devices, both with Android 13 and with proper internet connection.

Could you please provide any advice on how to solve or further diagnose this issue?

@saulojg saulojg changed the title Cannot use fetch inside scheduled Cannot use fetch inside scheduled runner Feb 26, 2024
@saulojg
Copy link
Author

saulojg commented Feb 26, 2024

This behavior is the same regardless of how the event is triggered (e.g.: auto-start or scheduled).

We've found we cannot use await fetch(...) since it just blocks the (scheduled) runner thread. Later on we'll try to help you expand the documentation regarding this behavior.

@louis123562
Copy link

Hey saulojg, we have a slightly different problem. We are unable to make any fetch() request from any Android version. We tried 10, 11, 13 and 14 - sometimes with DNS propagation errors or SSL Handshake excepetions.

I guess the poor implementation of the mystery javascript engine is responsible for these behaviours.

@saulojg saulojg mentioned this issue Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants