lightpanda-io / browser

The open-source browser made for headless usage
https://lightpanda.io
GNU Affero General Public License v3.0
158 stars 1 forks source link

cdp: refacto message JSON read #286

Closed krichprollsch closed 2 weeks ago

francisbouvier commented 3 weeks ago

The unit test of cdp/msg.zig should be added to run_tests.zig.

krichprollsch commented 2 weeks ago

After rebasing, I get an error during page.navigate

I don't understand why I get a info(server): close cmd, closing conn... message :thinking:

debug(cdp): Req > id 16, method page.navigate
debug(cdp): Event > method Page.frameStartedLoading, sessionID 4FDC2CB760A23A220497A05C95417CF4                                               
debug(cdp): Event > method Page.lifecycleEvent, sessionID 4FDC2CB760A23A220497A05C95417CF4  
debug(cdp): Res > id 16, sessionID 4FDC2CB760A23A220497A05C95417CF4, result cdp.page.navigate.Resp { .frameId = 57356548460A8F29706A2ADF14316298, .loaderId = 'AF8667A203C5392DBE9AC290044AA4C2 }
debug(cdp): Event > method Runtime.executionContextsCleared, sessionID 4FDC2CB760A23A220497A05C95417CF4
debug(browser): starting GET http://127.0.0.1:1234/campfire-commerce/
info(browser): GET http://127.0.0.1:1234/campfire-commerce/ http.Status.ok                                                                                                                                                                                                                
debug(browser): header content-type: text/html; charset=utf-8                                                                                 
debug(browser): parse html with charset utf-8                                                                                                 
debug(browser): start js env                                                                                                                  
debug(cdp): Event (inspector) > method "Runtime.executionContextCreated"                        
debug(browser): setup global env                                                                                                              
debug(browser): starting GET script.js                                                                                                        
debug(browser): starting fetch script script.js                                                                                               
info(browser): fech script http://127.0.0.1:1234/campfire-commerce/script.js: http.Status.ok     
debug(xhr): http.Method.GET http://127.0.0.1:1234/campfire-commerce/json/product.json              
debug(xhr): http.Method.GET http://127.0.0.1:1234/campfire-commerce/json/reviews.json                                                                                                                                                                                                     
debug(browser): eval remote script.js: function() {
    ProductImg.src = this.src;                                         
  }                                                                    
debug(cdp): Event > method Page.lifecycleEvent, sessionID 4FDC2CB760A23A220497A05C95417CF4                                                                                                                                                                                                
debug(cdp): Event > method Page.frameNavigated, sessionID 4FDC2CB760A23A220497A05C95417CF4         
debug(cdp): Event > method Page.domContentEventFired, sessionID 4FDC2CB760A23A220497A05C95417CF4                                                                                                                                                                                          
debug(cdp): Event > method Page.lifecycleEvent, sessionID 4FDC2CB760A23A220497A05C95417CF4                                                                                                                                                                                                
debug(cdp): Event > method Page.loadEventFired, sessionID 4FDC2CB760A23A220497A05C95417CF4                                                                                                                                                                                                
debug(cdp): Event > method Page.lifecycleEvent, sessionID 4FDC2CB760A23A220497A05C95417CF4                                                                                                                                                                                                
debug(cdp): Event > method Page.frameStoppedLoading, sessionID 4FDC2CB760A23A220497A05C95417CF4                                                                                                                                                                                           
info(xhr): http.Method.GET http://127.0.0.1:1234/campfire-commerce/json/product.json http.Status.ok                                                                                                                                                                                       
debug(xhr): dispatch progress event: loadstart
debug(xhr): dispatch progress event: progress                                                                                                 
debug(xhr): dispatch progress event: load                                                                                                    
debug(xhr): dispatch progress event: loadend                                                                                                 
info(server): close cmd, closing conn...                                                                                                     
info(xhr): http.Method.GET http://127.0.0.1:1234/campfire-commerce/json/reviews.json http.Status.ok                                                                                                                                                                                       
debug(xhr): dispatch progress event: loadstart                                                                                               
debug(xhr): dispatch progress event: progress                                                                                                
debug(xhr): dispatch progress event: load                                                                                                    
debug(xhr): dispatch progress event: loadend                                                                                                 
error(server): cancel error: error.NotFound                                                                                                  
error(server): Server error: error.NotFound                                                                                                  
thread 1340660 panic: reached unreachable code                                                                                               
/usr/local/zig-0.13.0/lib/std/debug.zig:412:14: 0x1a886ac in assert (lightpanda)                                                                                                                                                                                                          
    if (!ok) unreachable; // assertion failure                                                                                               
             ^                                                        
/home/pierre/wrk/browser/src/async/Client.zig:1234:11: 0x1b2509e in deinit (lightpanda)                                                                                                                                                                                                   
    assert(client.connection_pool.used.first == null); // There are still active requests.                                                                                                                                                                                                
          ^                                                           
/home/pierre/wrk/browser/src/browser/browser.zig:133:31: 0x1ad028a in deinit (lightpanda)                                                                                                                                                                                                 
        self.httpClient.deinit();                                     
                              ^                                       
/home/pierre/wrk/browser/src/browser/browser.zig:65:28: 0x1aace15 in deinit (lightpanda)                                                                                                                                                                                                  
        self.session.deinit();                                        
                           ^                                          
/home/pierre/wrk/browser/src/server.zig:445:25: 0x1aac993 in listen (lightpanda)                                                                                                                                                                                                          
    defer browser.deinit();                                           
                        ^                                             
/home/pierre/wrk/browser/src/main.zig:270:26: 0x1aaaed8 in main (lightpanda)                                                                                                                                                                                                              
        try server.listen(alloc, &loop, srv.sockfd.?, std.time.ns_per_s * @as(u64, timeout));                                                                                                                                                                                             
                         ^                                            
/usr/local/zig-0.13.0/lib/std/start.zig:524:37: 0x1aad22e in main (lightpanda)                                                                                                                                                                                                            
            const result = root.main() catch |err| {                                                                                         
                                    ^                                                                                                        
../sysdeps/nptl/libc_start_call_main.h:58:16: 0x7f26252ebd67 in __libc_start_call_main (../sysdeps/x86/libc-start.c)                                                                                                                                                                      
../csu/libc-start.c:360:3: 0x7f26252ebe24 in __libc_start_main_impl (../sysdeps/x86/libc-start.c)                                                                                                                                                                                         
???:?:?: 0x1a85020 in ??? (???)                                       
???:?:?: 0x0 in ??? (???)                                             
Aborted