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

Unhandled exception: Context is disposed #237

Open
plztrial4me opened this issue May 30, 2023 · 0 comments
Open

Unhandled exception: Context is disposed #237

plztrial4me opened this issue May 30, 2023 · 0 comments

Comments

@plztrial4me
Copy link

plztrial4me commented May 30, 2023

I'm using puppeteer version 3.0.0.

In the source code below, a exception is thrown only when the "siteUrl" value is https://www.naver.com.
However, it does not occur when the "siteUrl" value is https://www.google.com.

I haven't found what is causing the exception to be thrown. I need help.

The result of running the source code is shown below.

2023-05-30 16:24:00.005092: refresh()
2023-05-30 16:25:00.001224: refresh()
2023-05-30 16:26:00.002222: refresh()
2023-05-30 16:27:00.001646: refresh()
2023-05-30 16:28:00.001427: refresh()
2023-05-30 16:29:00.001050: refresh()
2023-05-30 16:30:00.001667: refresh()
2023-05-30 16:31:00.001120: refresh()
2023-05-30 16:32:00.002009: refresh()
2023-05-30 16:33:00.001106: refresh()
Unhandled exception:
Context is disposed

import "package:cron/cron.dart";
import "package:puppeteer/puppeteer.dart";

void main(List<String> arguments) async {
  const siteUrl = "https://www.naver.com";
  late final Browser browser;

  try {
    browser = await puppeteer.launch(
      headless: false,
      defaultViewport: null,
      args: [
        '-window-size=1920,1080',
        '--disable-web-security',
        '--disable-features=IsolateOrigins,site-per-process',
      ],
    );

    final cron = Cron();
    cron.schedule(Schedule.parse('*/1 * * * *'), () async {
      // Open a new tab to access the site and close it
      try {
        print('${DateTime.now().toString()}: refresh()');
        final page = await browser.newPage();
        await page.goto(siteUrl, wait: Until.networkIdle);
        await page.close();
      } catch (e, stack) {
        print('schedule exception');
        print(e);
        print(stack);
      }
    });

    final page = await browser.newPage();
    await page.goto(siteUrl);
  } catch (e, stack) {
    print('main exception');
    print(e);
    print(stack);
  }
}
Repository owner deleted a comment from rs5173 Jan 24, 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

1 participant