Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Expose the connection object, so the derivative class can revisit the…#267

Merged
roblourens merged 1 commit intomicrosoft:masterfrom
changsi-an:master
Jan 20, 2018
Merged

Expose the connection object, so the derivative class can revisit the…#267
roblourens merged 1 commit intomicrosoft:masterfrom
changsi-an:master

Conversation

@changsi-an
Copy link
Contributor

Expose the connection object, so the derivative class can revisit the targets as needed.

Currently the series of attach() method could not surface back the debugger id from the response of calling /json/list. Instead of refactoring the code and returning that, it might be cleaner to have the downstream logic query the targets again when needed.

@roblourens
Copy link
Member

Why do you need this? Do you need the attached target id, not the list of all target ids?

@changsi-an
Copy link
Contributor Author

"Do you need the attached target id"

Yes

@roblourens
Copy link
Member

So this won't work, because it will return all targets. You need to change the attach logic to make the selected target accessible. What's the use case?

@changsi-an
Copy link
Contributor Author

This PR only reflects the changes needed in chrome-core. My debug adapter will take care of the attach logic. It will call chromeConnection.attachedWebSocketUrl to get the current attached target wsUrl. then match that from the result of getting all targets. I didn't want to infuse this into chrome-core, because such need is specific to my debug adapter. The reason I do this PR this way hoping to make it open and general, so it can be useful for other purposes instead of scoped to a limited use case.

The code in my downstream debug adapter looks like this:


               this.doAttach(args...)
               .then(() => {
                    if (!this._chromeConnection.isAttached) {
                        throw coreUtils.errP(localize("edge.debug.error.notattached", "Debugging connection is not attached after the attaching process."));
                    }

                    let websocketUrl = this._chromeConnection.attachedWebSocketUrl;
                    this._debugProxyPort = port;

                    return this._chromeConnection.getAllTargets(args.address, port, (target: chromeConnection.ITarget) => {
                        return target.webSocketDebuggerUrl == websocketUrl;
                    })
                }).then((targets: chromeConnection.ITarget[]) => {
                    if (targets.length != 1) {
                        throw coreUtils.errP(localize("edge.debug.error.noSoleMatchingTarget", "Cannot determinte the attached target."));
                    }

                    this._debuggerId = targets[0].id;
                });

@roblourens
Copy link
Member

I can't think of any other reason for needing the websocket url anyway. Maybe exposing the whole attached target object would be useful. But please tell me what your actual use case is, because I don't understand why you need this id.

@changsi-an
Copy link
Contributor Author

This id is used to call a API provided in EDP to close a tab. The API has the form of *:9222/json/close/{id} . Hence the id is used there. We can't just breakdown Edge process entirely like we do for Chrome due to different process model is used for each browser.

I feel that dynamically retrieving the target is better than using the cached one. It's going to be a long time between the target is attached and when we need to use this id (debug finish). So far I am not sure whether edge is going to change any metadata of the target along the way. Even if the id might be fixated, I am not sure about the other metadata we might need to access along the way.

@roblourens
Copy link
Member

Good point that it will change along the way. I thought of one thing that would actually be kind of cool - we could show the window title in the call stack (while debugging multiple targets) instead of just "Chrome". Anyway, could you just change it to expose the attached ITarget?

@changsi-an
Copy link
Contributor Author

Exposing as ITarget is better. Will do!

@changsi-an changsi-an force-pushed the master branch 3 times, most recently from 789cafd to 345ef88 Compare January 19, 2018 22:14
@changsi-an
Copy link
Contributor Author

PTAL

@roblourens roblourens merged commit d439a66 into microsoft:master Jan 20, 2018
@roblourens roblourens added this to the January 2018 milestone Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants