feat: WebFrameMain.collectJavaScriptCallStack() (#44937)

* feat: WebFrameMain.unresponsiveDocumentJSCallStack

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* Revert "feat: WebFrameMain.unresponsiveDocumentJSCallStack"

This reverts commit e0612bc1a00a5282cba5df97da3c9c90e96ef244.

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* feat: frame.collectJavaScriptCallStack()

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* feat: frame.collectJavaScriptCallStack()

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* Update web-frame-main.md

Co-authored-by: Sam Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
trop[bot] 2024-12-03 09:55:43 -08:00 committed by GitHub
parent 7d2d5240bd
commit e1d9df224c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 131 additions and 1 deletions

View file

@ -142,6 +142,29 @@ ipcRenderer.on('port', (e, msg) => {
})
```
#### `frame.collectJavaScriptCallStack()` _Experimental_
Returns `Promise<string> | Promise<void>` - A promise that resolves with the currently running JavaScript call
stack. If no JavaScript runs in the frame, the promise will never resolve. In cases where the call stack is
otherwise unable to be collected, it will return `undefined`.
This can be useful to determine why the frame is unresponsive in cases where there's long-running JavaScript.
For more information, see the [proposed Crash Reporting API.](https://wicg.github.io/crash-reporting/)
```js
const { app } = require('electron')
app.commandLine.appendSwitch('enable-features', 'DocumentPolicyIncludeJSCallStacksInCrashReports')
app.on('web-contents-created', (_, webContents) => {
webContents.on('unresponsive', async () => {
// Interrupt execution and collect call stack from unresponsive renderer
const callStack = await webContents.mainFrame.collectJavaScriptCallStack()
console.log('Renderer unresponsive\n', callStack)
})
})
```
### Instance Properties
#### `frame.ipc` _Readonly_