koszti commented on pull request #15403: URL: https://github.com/apache/superset/pull/15403#issuecomment-876845016
> > Since FF is going to alert anyway with no real meaningful message, we could go ahead and put a `confirm` message for all browsers to ask the person if they want us to close their db connection when they leave. That also somewhat takes care of the configuration issue because people will have a choice > > I like this idea! I liked it too, it's elegant but turns out there are some problems. We can't check what the user answered in the page leave confirmation popup hence we can't stop the query conditionally. Checking the user's answer requires to introduce the [unload](https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event) event but in the `unload` event the react props are no longer available so we can't call the `this.stopQuery()` function. :( Using standard `window.confirm` would be a workaround but unfortunately we can't use `window.confirm` in `beforeunload` events. Using custom confirmation messages in the page leave popup is not allowed either. I made the following changes in 54da5e42cb0bef9c2d9bc15a5ba1a0c6870ec4c3: * It's checking the the query status and it triggers the mechanism only if the query is still running. This is to eliminate some race conditions. The only solution I can see to make the auto-kill optional is to introduce the "Cancel db query on window close" configurable option in the databases table but that'd require some changes in the core `/api/v1/database/` endpoint. I can add a new property into the `extra` JSON field to avoid db migration. But please let me know if you can see any simpler solution, before I start doing it. Changes in the core database API endpoint response could affect many other things. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
