wallabyjs / console-ninja

Repository for Console Ninja questions and issues
https://console-ninja.com
Other
384 stars 21 forks source link

[Bug]: Doesn't work when script tag is before body #255

Closed tjx666 closed 10 months ago

tjx666 commented 10 months ago

What happened?

code:

<!DOCTYPE html>
<html lang="en">
    <script>
        const start = Date.now();
        const logEvent = (e) => {
            console.log(e.type, Date.now() - start, e);
        };

        window.addEventListener('DOMContentLoaded', (e) => {
            logEvent(e);
        });

        window.addEventListener('load', (e) => {
            logEvent(e);

            const { timing } = performance;

            console.log('navigationStart', timing.navigationStart);
            console.log('fetchStart', timing.fetchStart);
            console.log('domainLookupStart', timing.domainLookupStart);
            console.log('requestStart', timing.requestStart);
        });

        console.log('parse DOM start', Date.now() - start);
    </script>
    <link rel="stylesheet" href="./reset.css" />
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <img
            src="https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming/timestamp-diagram.svg"
            alt="timing"
        />
    </body>
</html>

preview:

image

Version

v1.0.270

Steps to reproduce (or sample repo)

just use live preview with above code.

Log output

info host ------------ starting ------------
16:09:57.141 info host removing cache folder: 0739928010d368014c2ffc5f93cf5859
16:09:57.142 info host removing cache folder: 14bcf189ec094d43bfaab9c78007cc5c
16:09:57.144 info extension 
16:09:57.146 info host client connected: extension { address: '::', family: 'IPv6', port: 56429 }
16:09:57.155 info host starting host: {"extensionFolder":"/Users/yutengjing/.vscode-insiders/extensions/wallabyjs.console-ninja-1.0.270","runtimeHookFile":"/Users/yutengjing/.vscode-insiders/extensions/wallabyjs.console-ninja-1.0.270/out/runtimeHook/tracer.js","globalErrorHandlerFile":"/Users/yutengjing/.vscode-insiders/extensions/wallabyjs.console-ninja-1.0.270/out/runtimeHook/errorHandler.js","filesToInstrument":[{"path":"/users/yutengjing/code/fe-demos/prettier-browser/index.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/observers/mutationobserver.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/performance/timing.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/forbbid-copy/copy.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/node/event-loop.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/node/weak.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/node/gc.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/clone/message-channel.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/compare-version.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/add2.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/findkthlargest1.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/lru.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/my-atoi.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/findkthlargest2.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/clone/test.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/server/cookie-max-size.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/storage/local-storage.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/server/cookie-max-count.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/server/test.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/leetcode-hot/add1.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/text-content/index.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/cross-tab-share/sharedworker.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/cross-tab-share/bordercastchannel.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/html5/data.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/sort/select-swap-sort.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/sort/bubble-sort.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/sort/quick-sort1.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/delay-when-in-background.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/sort/quick-sort2.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/valueof.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/prototype/instanceof.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/cross-tab-share/localstorage.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/sort/insert-sort.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/sort/shuffle.ts","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/prototype/new.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/async-error.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/listener/event-model.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/prototype/test.mjs","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/listener/options.html","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/jsvascript/lazysum.js","reason":"search"},{"path":"/users/yutengjing/code/fe-demos/listener/register-ways.html","reason":"search"},{"path":"/Users/yutengjing/code/fe-demos/performance/timing.html","reason":"open"},{"path":"/Users/yutengjing/code/fe-demos/html5/data.html","reason":"open"}],"debug":false,"config":{"dateTimeFormat":"HH:mm:ss.SSS","dateTimeDisplayMode":"Absolute","installBinToPath":true,"openLinksInEditor":true,"maxLogViewerEntries":15000,"fontSize":10,"autoClearLogViewerOnFileChanges":true,"outputMode":"Beside File","captureFunctions":false,"searchUrl":"https://www.google.com/search?q={query}","enableProFeatures":false,"toolsToAutoPatch":["vite","jest","webpack","next.js","cypress","http-server","serve","live-server","nuxt","live-server-extension","live-preview-extension"],"showErrors":true,"showLogsOnlyFromOpenedFiles":false,"showLogsFromLogPointsOnly":false,"showLogsFromMultipleRunningToolsTogether":false,"predictiveLoggingEnabled":true,"allowConsoleLogToTriggerPredictions":false},"allowedHosts":["localhost","127.0.0.1","example.cypress.io","YuTengjingdeMacBook-Pro.local","192.168.10.15"],"host":"127.0.0.1"}
16:09:57.162 info host starting tools discovery and integration
16:09:57.168 info host looking for tools to patch
16:09:57.212 info host found 2 tool file(s) to patch
16:09:57.212 info host patching /Users/yutengjing/.vscode-insiders/extensions/ritwickdey.liveserver-5.7.9/node_modules/live-server/index.js
16:09:57.212 info host patching /Users/yutengjing/.vscode-insiders/extensions/ms-vscode.live-server-0.4.13/out/extension.js
16:09:57.236 info host worker Starting Host Worker...
16:09:57.251 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:09:57.267 info host completed tools discovery and integration
16:09:57.680 info buildHook-94007 allowed tools: vite, jest, webpack, next.js, cypress, http-server, serve, live-server, nuxt, live-server-extension, live-preview-extension, node
16:09:57.680 info buildHook-94007 running tools: live-preview-extension
16:09:57.684 info host client connected: buildHook { address: '::', family: 'IPv6', port: 56429 }
16:09:57.685 info buildHook-94007 allowed tools: vite, jest, webpack, next.js, cypress, http-server, serve, live-server, nuxt, live-server-extension, live-preview-extension, node
16:09:57.685 info buildHook-94007 running tools: live-preview-extension
16:09:59.095 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:00.838 info buildHook-94007 file processed (stat): 6 log points, error handler: true
16:10:06.736 info buildHook-94007 file processed (stat): 2 log points, error handler: true
16:10:06.744 info host client disconnected: runtimeHook 1001
16:10:06.744 info host client disconnected: runtimeHook
16:10:06.745 info host client disconnected: runtimeHook 1001
16:10:06.745 info host client disconnected: runtimeHook
16:10:09.420 info buildHook-94007 file processed (stat): 6 log points, error handler: true
16:10:10.777 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:13.693 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:21.297 info host client disconnected: runtimeHook 1001
16:10:21.297 info host client disconnected: runtimeHook
16:10:21.297 info host client disconnected: runtimeHook 1001
16:10:21.297 info host client disconnected: runtimeHook
16:10:22.194 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:23.044 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:23.240 info buildHook-94007 file processed (stat): 6 log points, error handler: true
16:10:23.799 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:23.811 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:25.380 info host client disconnected: runtimeHook 1001
16:10:25.380 info host client disconnected: runtimeHook
16:10:25.381 info host client disconnected: runtimeHook 1001
16:10:25.381 info host client disconnected: runtimeHook
16:10:25.642 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:25.655 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:44.081 info host client disconnected: runtimeHook 1001
16:10:44.081 info host client disconnected: runtimeHook
16:10:44.081 info host client disconnected: runtimeHook 1001
16:10:44.081 info host client disconnected: runtimeHook
16:10:44.339 info host client disconnected: runtimeHook 1001
16:10:44.339 info host client disconnected: runtimeHook
16:10:44.339 info host client disconnected: runtimeHook 1001
16:10:44.339 info host client disconnected: runtimeHook
16:10:44.348 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:44.359 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:44.595 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:44.606 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:44.621 info host client disconnected: runtimeHook 1001
16:10:44.621 info host client disconnected: runtimeHook
16:10:44.621 info host client disconnected: runtimeHook 1001
16:10:44.621 info host client disconnected: runtimeHook
16:10:44.846 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:44.859 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:45.097 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:45.109 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:46.174 info buildHook-94007 file processed (stat): 6 log points, error handler: true
16:10:48.043 info host client disconnected: runtimeHook 1001
16:10:48.043 info host client disconnected: runtimeHook
16:10:48.044 info host client disconnected: runtimeHook 1001
16:10:48.044 info host client disconnected: runtimeHook
16:10:48.049 info host client disconnected: runtimeHook 1001
16:10:48.049 info host client disconnected: runtimeHook
16:10:48.050 info host client disconnected: runtimeHook 1001
16:10:48.050 info host client disconnected: runtimeHook
16:10:48.093 info buildHook-94007 file processed (stat): 6 log points, error handler: true
16:10:48.296 info host client disconnected: runtimeHook 1001
16:10:48.296 info host client disconnected: runtimeHook
16:10:48.296 info host client disconnected: runtimeHook 1001
16:10:48.296 info host client disconnected: runtimeHook
16:10:48.559 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:10:48.570 info host client connected: runtimeHook { address: '::', family: 'IPv6', port: 56429 }
16:12:40.835 info buildHook-94007 file processed (sync): 0 log points, error handler: true
ArtemGovorov commented 10 months ago

Thanks for the report. The issue has been fixed and the fix has been published in v1.0.271 of the extension.