Commit 301d513
feat(hackbrowser): enrich browser-lifecycle logs + log popups for partial-crawl diagnosis (#105)
The worker already listened for browser.disconnected / page.close / page.crash, but logged a
terse one-line message with no context, and never logged a popup/new tab opening — so a crawl
that stopped early left little to diagnose from. Add a guarded lifecycleContext(browser, page?)
helper (url, open-page count, isConnected — every read wrapped so a crash/disconnect handler
can never throw while gathering diagnostics) and attach its output to the existing terminal
logs on BOTH the single- and multi-credential paths. Also add a context "page" listener that
logs (debug) when a popup/tab opens, with the same context — no such listener existed.
Scope kept proportionate: no dedicated per-session log file (worker logs are already persisted
via the parent's log pipeline, and #104 removed the main mid-crawl crash, so the crash-window
loss the file would guard is now rare), no verbosity flag, no crawl-progress plumbing.
Verified: a real crawl that opens a popup logs "new page/popup opened" with {url, openPages,
connected} and the terminal logs now carry the same context; the guarded reads don't throw
even on a not-yet-committed popup URL or a disconnected browser; 99/99 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 3f7e082 commit 301d513
1 file changed
Lines changed: 35 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
123 | 138 | | |
124 | | - | |
| 139 | + | |
125 | 140 | | |
126 | 141 | | |
127 | 142 | | |
128 | 143 | | |
129 | | - | |
| 144 | + | |
130 | 145 | | |
131 | 146 | | |
132 | 147 | | |
133 | 148 | | |
134 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
135 | 155 | | |
136 | 156 | | |
137 | 157 | | |
| |||
1864 | 1884 | | |
1865 | 1885 | | |
1866 | 1886 | | |
1867 | | - | |
| 1887 | + | |
1868 | 1888 | | |
1869 | 1889 | | |
1870 | 1890 | | |
| |||
1897 | 1917 | | |
1898 | 1918 | | |
1899 | 1919 | | |
1900 | | - | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
1901 | 1924 | | |
1902 | 1925 | | |
1903 | 1926 | | |
1904 | 1927 | | |
1905 | | - | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
1906 | 1935 | | |
1907 | 1936 | | |
1908 | 1937 | | |
| |||
0 commit comments