Skip to content

setYield(true) in last handler does not trigger 404 response #1164

@VanillaMaster

Description

@VanillaMaster

version: v20.51.0
platform: Microsoft Windows NT 10.0.19045.0 x64

calling setYield breaks default handler
i can assume it is a bug or undocumented behavior
in both cases fix is required

example:

import { App } from "uWebSockets.js";

const app = App();
app.listen(8080, function(token) {
    if (!token) console.error(`Failed to start listening`)
})

request to example above results in the following response

> GET / HTTP/1.1
> Host: localhost:8080
> Accept: */*

< HTTP/1.1 404 File Not Found
< Date: Mon, 21 Apr 2025 13:28:41 GMT
< uWebSockets: 20
< Content-Length: 81

with body

<html><body><h1>File Not Found</h1><hr><i>uWebSockets/20 Server</i></body></html>

but when any listener that just yields attached

import { App } from "uWebSockets.js";

const app = App();
app.any("/*", function(res, req) {
    console.log(req.getMethod(), req.getUrl());
    req.setYield(true);
});
app.listen(8080, function(token) {
    if (!token) console.error(`Failed to start listening`)
})

same request fails

> GET / HTTP/1.1
> Host: localhost:8080
> Accept: */*

* Empty reply from server
* Closing connection 60

problem can be solved with attachment of explicit default handler

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions