Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

fix: capturing not stop after devtools being closed in capturing state #48

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/capturer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ const startCapturing = () => {
window.__opensumi_devtools.capture = (message) => {
if (window.__opensumi_devtools.evaling) return;

// if the length of messages is greater than 9999, devtools window
// is regarded to be closed in capturing state. So stop capturing.
if (window.__opensumi_devtools.messages.length > 9999) {
window.__opensumi_devtools = undefined;
return;
}

const msg = {
time: new Date().toLocaleString().split(' ')[1],
type: message.type,
Expand Down Expand Up @@ -67,6 +74,7 @@ const stopCapturing = () => {
const getMessages = () => {
return evalInWindow(() => {
const messages = window.__opensumi_devtools.messages;
// clear messages after getting them each time
if (messages) window.__opensumi_devtools.messages = [];
return messages;
}).then((messages) => {
Expand Down