-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Cannot find context with specified id" #286
Comments
I hope you’re doing well. Would you be able to find some time to look into the reported issue and work on a fix? Your assistance would be greatly appreciated. |
@eNcacz I'd love to find time to take a look at this but my plate is still quite full. If you have any ability to wire up a unit test like we did for the last one and see where it's breaking (it will be somewhere in agent/lib/FramesManager or Frame), that will be your best option for a quicker resolution |
@blakebyrnes I looked into the problem and found the cause in the Frame in @ulixee/unblocked-agent. It is caused by: public async getContainerOffset(): Promise<IPoint> {
// This gets called on .isConnected() and this.getBoundingClientRect(); causes problem
// if context changes and node with the frameElementNodeId no longer exists.
// It can happen besause this.getFrameElementDevtoolsNodeId(); gets the real node id once
// and on every subsequent call it returns the cached value.
if (!this.parentId) return { x: 0, y: 0 };
const parentOffset = await this.parentFrame.getContainerOffset();
const frameElementNodeId = await this.getFrameElementDevtoolsNodeId();
const thisOffset = await this.parentFrame.evaluateOnNode<IPoint>(
frameElementNodeId,
`(() => {
const rect = this.getBoundingClientRect();
return { x:rect.x, y:rect.y };
})()`,
);
return {
x: thisOffset.x + parentOffset.x,
y: thisOffset.y + parentOffset.y,
};
} and can be solved with change in evaluateOnNode: public async evaluateOnNode<T>(devtoolsObjectId: string, expression: string): Promise<T> {
if (this.closedWithError) throw this.closedWithError;
try {
// PROPOSED SOLUTION - Test if the node is still there,
// if it is not the Runtime.callFunctionOn will throw an unhandled error.
// Other solution would be test this in getFrameElementDevtoolsNodeId() and throw error if it is not there.
await this.parentFrame.devtoolsSession.send('DOM.getFrameOwner', { frameId: this.id }, this);
const result = await this.devtoolsSession.send(
'Runtime.callFunctionOn',
{
functionDeclaration: `function executeRemoteFn() {
return ${expression};
}`,
returnByValue: true,
objectId: devtoolsObjectId,
},
this,
);
if (result.exceptionDetails) {
throw ConsoleMessage.exceptionToError(result.exceptionDetails);
}
const remote = result.result;
if (remote.objectId) this.devtoolsSession.disposeRemoteObject(remote);
return remote.value as T;
} catch (err) {
if (err instanceof CanceledPromiseError) return;
throw err;
}
} |
I already reported this error as issue 263. The testcase from that issue now works well in 2.0.0-alpha.29, but the error still appears in my project.
So I prepared another testcase which is failing in 2.0.0-alpha.29.
We need these two html files:
browserFrameTestParent.html
browserFrameTestFrame.html
And this is the test script:
When I run the script, then the output looks like this:
The text was updated successfully, but these errors were encountered: