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

Nightmare process won't exit if page has confirm dialog on page exit #824

Closed
Fauntleroy opened this issue Oct 11, 2016 · 4 comments
Closed

Comments

@Fauntleroy
Copy link
Contributor

When trying to .end() a nightmare instance the process will hang forever if there is a confirm dialog on page exit. The confirm dialog is also not visible.

Code:

var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });

nightmare
  .goto('https://docs.google.com/forms/d/e/1FAIpQLSe2SK5Vzy82yB9SjLI5B3zfrR1QEaxyjyRGvVxWp_K66p31ZA/viewform')
  .type('input[name="entry.1921379240"]', 'NodeSchool Oakland')
  .end()
  .then(function () {});

My view of the electron window:

screen shot 2016-10-10 at 6 29 43 pm

Is there some way to forcefully close the nightmare instance?

@Fauntleroy
Copy link
Contributor Author

I have isolated the issue. It seems that Google Forms is setting the unload event and preventing navigation with the special unload confirm dialog.

I have a temporary fix right now:

  • Hijack window.addEventListener and silently kill attempts to bind unload events
  • Make window.onunload and window.onbeforeunload unwritable properties

I'll probably submit a pull req after I've cleaned up my solution.

@rosshinkley
Copy link
Contributor

For what it's worth, you could instead prop up a custom preload to handle the confirm case manually. By default, the confirm handler returns the default response, which in this case is probably to stay on the page.

@Fauntleroy
Copy link
Contributor Author

@rosshinkley in this case, window.confirm isn't the issue, it's the unload and onbeforeunload handlers. I managed to fix it with a custom preload.js script, which I've submitted in a pull request here: #825

@rosshinkley
Copy link
Contributor

Fixed with #825. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants