geckodriver icon indicating copy to clipboard operation
geckodriver copied to clipboard

Calling Delete Session after Close Window causes 500 Internal Server Error

Open raviautomation09 opened this issue 8 years ago • 16 comments

In order to help us efficiently investigate your issue, please provide the following information:

Firefox Version

53.0.2 (32-bit)

Platform

Windows

driver version

16.0.1

Selenium Version

3.4.0

Steps to reproduce -

Below is the step to reproduce

  • [ ] A create driver object and launch the browser
  • [ ] Perform driver.close()
  • [ ] Perform driver.quit()

Logs-

Tried to run command without establishing a connection

Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'XXXXXXX', ip: 'XX.XX.XX.XXX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\h124795\AppData\Local\Temp\rust_mozprofile.0K9aVa2cfwmA, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0.2, platformVersion=10.0, moz:processID=6048.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt}]
Session ID: 28f25c88-bf88-43e5-9111-18bd9bdff2d6

** If any of the above are missing we will have to unfortunately close your issue. We will gladly reopen the issue once all the information requested has been added **

raviautomation09 avatar May 10 '17 12:05 raviautomation09

@raviautomation09 Can you please try use the latest nightly. I think this issue might have already been fixed but want to check.

If it still fails can you add the verbose log from GeckoDriver. You may need to look up in your driver bindings how to do that.

AutomatedTester avatar May 10 '17 22:05 AutomatedTester

@raviautomation09 If you can't test this out by Monday next week (22 May) I will unfortunately need to close this issue.

AutomatedTester avatar May 15 '17 10:05 AutomatedTester

The issue still persist after executing on Nightly. Below is the logs when driver.close() and driver.quit() is called:

driver.close():

1494925525976 webdriver::server DEBUG → DELETE /session/fe8a6452-f0e8-4755-afe1-2bd38e2dc55d/window 1494925525991 geckodriver::marionette TRACE → 16:[0,7,"close",{}] 1494925525996 Marionette TRACE 0 -> [0,7,"close",{}] 1494925525997 Marionette TRACE 0 <- [1,7,null,[]] 1494925525993 geckodriver::marionette TRACE � [1,7,null,[]] 1494925525993 webdriver::server DEBUG Last window was closed, deleting session 1494925525993 webdriver::server DEBUG Deleting session 1494925525993 geckodriver::marionette DEBUG Stopping browser process 1494925526180 webdriver::server DEBUG � 200 OK {"value": []}

driver.quit():

1494925526682 webdriver::server DEBUG → DELETE /session/fe8a6452-f0e8-4755-afe1-2bd38e2dc55d 1494925526682 webdriver::server DEBUG � 500 Internal Server Error {"value":{"error":"unknown error","message":"Tried to run command without establishing a connection","stacktrace":"stack backtrace:\n 0: 0x47f1a6 - \n 1: 0x437103 - \n 2: 0x41a4d2 - \n 3: 0x40570c - \n 4: 0x692906 - \n 5: 0x413838 - \n 6: 0x68d401 - \n 7: 0x765b38f4 - BaseThreadInitThunk\n 8: 0x76f35de3 - RtlUnicodeStringToInteger"}} 1494925526714 webdriver::server DEBUG → GET /shutdown 1494925526729 webdriver::server DEBUG � 404 Not Found {"value":{"error":"unknown command","message":"GET /shutdown did not match a known command","stacktrace":"stack backtrace:\n 0: 0x47f1a6 - \n 1: 0x437327 - \n 2: 0x430657 - \n 3: 0x422b61 - \n 4: 0x406a80 - \n 5: 0x692906 - \n 6: 0x413c76 - \n 7: 0x68d401 - \n 8: 0x765b38f4 - BaseThreadInitThunk\n 9: 0x76f35de3 - RtlUnicodeStringToInteger"}}

Selenium Exception:

Tried to run command without establishing a connection Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'IE1FLT85RHJC2', ip: '10.78.192.215', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=C:\Users\h124795\AppData\Local\Temp\rust_mozprofile.eku2Luin3ZBy, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=55.0a1, platformVersion=10.0, moz:processID=11780.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt}] Session ID: fe8a6452-f0e8-4755-afe1-2bd38e2dc55d

raviautomation09 avatar May 16 '17 09:05 raviautomation09

@raviautomation09 Are you calling close and then quit? Its near impossible to solve this issue when you are only giving snippets of the log. We can't see what is happening around which could solve this problem.

Please give a full snippet, from session create to after the errors have happened. If we do not get the full log unfortunately we will need to close this issue as won't fix.

AutomatedTester avatar May 22 '17 09:05 AutomatedTester

Do you run driver.quit() after driver.close()? If yes this will not work given that the close() command already closed the last window of Firefox, and as such the application already shutdown. So calling quit() afterward doesn't make sense.

Also I can see the following in the log for quit(): GET /shutdown did not match a known command. Is this a problem with your binding? It's not clear which one and which version you are using. So please report those details.

whimboo avatar May 24 '17 07:05 whimboo

We should probably not return a 500 Internal Server Error when driver.quit() is called after a driver.close() implicitly ends the session.

The specification’s definition of the Delete Session command is:

  1. Try to close the session.
  2. Return success with data null.

You could interpret this the way geckodriver currently does, and return an error from step 1 because there is no Marionette connection (internal error), or you could try to end the session and if there is no session, return success anyway.

I think probably a specification clarification is needed here. For compatibility with other WebDriver implementations I think there should be a step 0 in Delete Session that returns immediately if there is no active session.

@AutomatedTester What do you think?

andreastt avatar May 24 '17 14:05 andreastt

@AutomatedTester mind giving us some feedback about the proposal from @andreastt ?

whimboo avatar May 30 '17 15:05 whimboo

we should do

I think probably a specification clarification is needed here. For compatibility with other WebDriver implementations I think there should be a step 0 in Delete Session that returns immediately if there is no active session.

AutomatedTester avatar May 31 '17 12:05 AutomatedTester

I submitted https://github.com/w3c/webdriver/pull/926 to the specification.

andreastt avatar May 31 '17 17:05 andreastt

For geckodriver we track the work in https://bugzilla.mozilla.org/show_bug.cgi?id=1403510.

whimboo avatar Jun 01 '18 09:06 whimboo

Also I can see the following in the log for quit(): GET /shutdown did not match a known command. Is this a problem with your binding? It's not clear which one and which version you are using. So please report those details.

Thank you it helps me to solve my problem running tests on Firefox driver

pallaviyesane avatar Jul 27 '20 10:07 pallaviyesane

Hello, I am using geckodriver 0.24 and firefox and I encountered the same original issue (which is closed now,so that is why I made the comment here ) https://github.com/mozilla/geckodriver/issues/1512 But with a major difference. The steps to generate the error didn't include delete session and this issue can't be reproduced always. This is the log: Failed to click element id=main-action-create after retrying 5 times with error Message: Tried to run command without establishing a connection Teardown:

Capture Page Screenshot Documentation: Takes screenshot of the current page and embeds it into log file. Start / End / Elapsed: 20200831 20:10:17.367 / 20200831 20:10:17.370 / 00:00:00.003 20:10:17.367 TRACE Arguments: [ ] 20:10:17.367 DEBUG GET http://127.0.0.1:36537/session/5012d69a-7726-47ba-919d-587e1d777790/screenshot {} 20:10:17.369 DEBUG Finished Request 20:10:17.369 TRACE Return: None 20:10:17.370 FAIL InvalidSessionIdException: Message: Tried to run command without establishing a connection

sofiand-png avatar Sep 01 '20 08:09 sofiand-png

The steps to generate the error didn't include delete session and this issue can't be reproduced always.

@sofiand-png so why are you adding the comment on this issue then? If it's not related please file a new issue. Thanks.

whimboo avatar Sep 01 '20 08:09 whimboo

The steps to generate the error didn't include delete session and this issue can't be reproduced always.

@sofiand-png so why are you adding the comment on this issue then? If it's not related please file a new issue. Thanks.

Because you set the original ticket as a duplicate of this one (although I don't see that clearly), so they should have the same root cause according to you. Isn't it ?

sofiand-png avatar Sep 01 '20 08:09 sofiand-png

Again, this issue is about the "Delete Session" command and not anything else.

whimboo avatar Sep 01 '20 09:09 whimboo

5 years on, and still no real solution to this problem?!

assaf-itzikson avatar Aug 05 '22 10:08 assaf-itzikson