Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable DOMErr code #366

Open
krichprollsch opened this issue Jan 20, 2025 · 1 comment · May be fixed by #367
Open

Unreachable DOMErr code #366

krichprollsch opened this issue Jan 20, 2025 · 1 comment · May be fixed by #367
Assignees
Labels
bug Something isn't working

Comments

@krichprollsch
Copy link
Member

With the url https://recipe-search.typesense.org/?r%5Bquery%5D=Pizza the browser crashes.

$ zig build run -- --dump  'https://recipe-search.typesense.org/?r%5Bquery%5D=Pizza' |tee /tmp/out                                                                                                                               
debug(cli): Fetch mode: url https://recipe-search.typesense.org/?r%5Bquery%5D=Pizza, dump true                                                                                                                                   
debug(browser): start js env                                                                                                                                                                                                     
debug(browser): setup global env                                                                                                                                                                                                 
debug(polyfill): load polyfill-fetch: undefined                                                                                                                                                                                  
debug(browser): starting GET https://recipe-search.typesense.org/?r%5Bquery%5D=Pizza                                                                                                                                             
info(browser): GET https://recipe-search.typesense.org/?r%5Bquery%5D=Pizza 200                                                                                                                                                   
debug(browser): http.Version.HTTP/1.1 200 OK                                                                                                                                                                                     
debug(browser): header content-type: text/html                                                                                                                                                                                   
debug(browser): parse html with charset utf-8                                                                                                                                                                                    
debug(browser): eval script inline: undefined                                                                                                                                                                                    
debug(browser): starting GET https://recipe-search.typesense.org/app.508a5130.js                                                                                                                                                 
debug(browser): starting fetch https://recipe-search.typesense.org/app.508a5130.js                                                                                                                                               
info(browser): fetch https://recipe-search.typesense.org/app.508a5130.js: http.Status.ok                                                                                                                                         
info(browser): eval script https://recipe-search.typesense.org/app.508a5130.js: Error: TypeError                                                                                                                                 
    at a (https://recipe-search.typesense.org/app.508a5130.js:492:292)                                                                                                                                                           
    at https://recipe-search.typesense.org/app.508a5130.js:492:533                                                                                                                                                               
    at parcelRequire.Rpqp../../utils (https://recipe-search.typesense.org/app.508a5130.js:492:645)                                                                                                                               
    at f (https://recipe-search.typesense.org/app.508a5130.js:1:468)                                                                                                                                                             
    at p (https://recipe-search.typesense.org/app.508a5130.js:1:544)                                                                                                                                                             
    at parcelRequire.akUF../../utils (https://recipe-search.typesense.org/app.508a5130.js:494:217)                                                                                                                               
    at f (https://recipe-search.typesense.org/app.508a5130.js:1:468)                                                                                                                                                             
    at p (https://recipe-search.typesense.org/app.508a5130.js:1:544)                                                                                                                                                             
    at i (https://recipe-search.typesense.org/app.508a5130.js:497:298)                                                                                                                                                           
    at parcelRequire.A14q../utils (https://recipe-search.typesense.org/app.508a5130.js:497:440)                                                                                                                                  
debug(browser): starting GET https://www.googletagmanager.com/gtag/js?id=UA-116415641-4                                                                                                                                          
debug(browser): starting fetch https://www.googletagmanager.com/gtag/js?id=UA-116415641-4                                                                                                                                        
info(browser): fetch https://www.googletagmanager.com/gtag/js?id=UA-116415641-4: http.Status.ok                                                                                                                                  
info(browser): eval script https://www.googletagmanager.com/gtag/js?id=UA-116415641-4: Error: NotImplemented                                                                                                                     
    at Cp (https://www.googletagmanager.com/gtag/js?id=UA-116415641-4:312:53)                                                                                                                                                    
    at Ap (https://www.googletagmanager.com/gtag/js?id=UA-116415641-4:305:724)                                                                                                                                                   
    at https://www.googletagmanager.com/gtag/js?id=UA-116415641-4:569:250                                                                                                                                                        
    at https://www.googletagmanager.com/gtag/js?id=UA-116415641-4:571:387                                                                                                                                                        
    at https://www.googletagmanager.com/gtag/js?id=UA-116415641-4:581:3                                                                                                                                                          
debug(browser): starting GET https://buttons.github.io/buttons.js                                                                                                                                                                
debug(browser): starting fetch https://buttons.github.io/buttons.js                                                                                                                                                              
info(browser): fetch https://buttons.github.io/buttons.js: http.Status.ok                                       
info(browser): eval script https://buttons.github.io/buttons.js: TypeError: Cannot read properties of undefined (reading 'protocol')
    at https://buttons.github.io/buttons.js:6:18769                                                             
    at https://buttons.github.io/buttons.js:6:19362                                                             
thread 455323 panic: reached unreachable code                                                                   
/home/pierre/wrk/browser/src/netsurf/netsurf.zig:396:17: 0x1ae17cc in DOMErr (lightpanda)                       
        else => unreachable,                                                                                    
                ^                                                                                               
/home/pierre/wrk/browser/src/netsurf/netsurf.zig:1020:15: 0x1ae2ed7 in nodeType (lightpanda)                    
    try DOMErr(err);                                                                                                                                                                                                             
              ^                                                                                                 
/home/pierre/wrk/browser/src/dom/node.zig:74:43: 0x1f4eb5c in toInterface (lightpanda)                          
        return switch (try parser.nodeType(node)) {                                                                                                                                                                              
                                          ^                                                                     
/home/pierre/wrk/browser/src/dom/event_target.zig:45:36: 0x1fbfe15 in toInterface (lightpanda)                  
        return Nod.Node.toInterface(@as(*parser.Node, @ptrCast(et)));                                                                                                                                                            
                                   ^                                                                                                                                                                                             
/home/pierre/wrk/browser/src/events/event.zig:84:43: 0x1fbffdd in get_target (lightpanda)                                                                                                                                        
        return try EventTarget.toInterface(et.?);                                                               
                                          ^                                                                     
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:920:9: 0x1e0acc7 in callFunc__anon_29968 (lightpanda)
        res = @call(.auto, function, args) catch |err| {                                                        
        ^                                              
@krichprollsch krichprollsch added the bug Something isn't working label Jan 20, 2025
@krichprollsch krichprollsch self-assigned this Jan 20, 2025
@krichprollsch
Copy link
Member Author

The initial issue comes from an Window event target bad casted as Node.

Indeed, the browser dispatches a load event with Window target https://github.com/lightpanda-io/browser/blob/main/src/browser/browser.zig#L507-L511

But the event target toInterface cast all targets as Node, see https://github.com/lightpanda-io/browser/blob/main/src/dom/event_target.zig#L43-L45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant