-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
CLI: close tab when we're done with it. #1543
Conversation
resolve(JSON.parse(data)); | ||
return; | ||
} catch (e) { | ||
if (data === 'Target is closing') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chromium code that handles this says
SendJson(connection_id, net::HTTP_OK, NULL, "Target is closing");
But unfortunately, SendJson
doesn't send JSON in this case. It sends this raw string.
Thus, the try/catch on this guy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you add some variant of this as a comment in the code? At least for the string being checked against
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup!
this._ws.close(); | ||
this._ws = null; | ||
return Promise.resolve(); | ||
return this._runJsonCommand(`close/${this._pageId}`).then(_ => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this close the browser too if it's the last tab left?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will not. It'll close the "window" but not the application.
return this._runJsonCommand(`close/${this._pageId}`).then(_ => { | ||
this._ws.removeAllListeners(); | ||
this._ws.close(); | ||
this._ws = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know when we'd ever reuse a cri connection instance, but since we null out _ws
, null out _pageId
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair. done.
} catch (e) { | ||
if (data === 'Target is closing') { | ||
return resolve({message: data}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have the try/catch now, want to add a return reject(e)
here, even though it wasn't caught in the promise chain before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg
PTAL |
looks like some of the gather-runner tests failed because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 📂➡️📁➡️💥
Fixes #1419