If a worker is in the middle of a database transaction, and the user closes the browser, does the database transaction correctly roll back before the worker is killed?
2008/11/7 Aaron Boodman <[EMAIL PROTECTED]> > > If you do the database action in the ui thread -- that is *not* in a > worker, it "should" work. However, you should be careful not to do too > much work because blocking in window.onunload would slow down page > navigation. > > If you send a message to a worker in onload and try to do the database > work there, I think the behavior is undefined. It might or might not > work, and it might also vary across browsers. > > All that said, it's usually best to avoid relying on window.unload. > There is no guarantee that it will get called. For example, it won't > in the case of a browser crash. It can be a good idea to use > window.onunload as an optimization, but your application should be > robust against it never getting called. > > HTH, > > - a > > On Mon, Nov 3, 2008 at 12:14 PM, Travis <[EMAIL PROTECTED]> wrote: > > > > So that being said, are there any implications with using Gears to > > perform a local database action on window.onunload or would the > > browser prevent that? > > > > On Nov 2, 4:04 pm, Chris Prince <[EMAIL PROTECTED]> wrote: > >> Yes, workers stop executing when the browser is closed. Workers do > >> not have any opportunity to run "last-chance" code. > >> > >> The reasons for this are: > >> * Users generally don't like their actions to be delayed, especially > >> when they try to close a program. > >> * Even if workers could run some final code: > >> (a) it's unclear how many milliseconds longer the workers > >> should be allowed to run, and > >> (b) no matter how many milliseconds were chosen, worker > >> code could not rely on any particular actions completing, > >> because the amount of work you can do in N msec will > >> vary widely between machines. > >> > >> > >> > >> On Fri, Oct 31, 2008 at 4:45 PM, Travis <[EMAIL PROTECTED]> > wrote: > >> > >> > I was wondering if a worker process stops when the browser closes > >> > regardless of whether its completed or not? > >> > >> > I am trying to implement a background process that runs a long running > >> > PHP file via the XMLHttpRequest module and I would like to store its > >> > return data in the Gears database.- Hide quoted text - > >> > >> - Show quoted text - > > > -- Best, Brad [EMAIL PROTECTED]
