Skip to content

[Bug]: HttpServer 多次报错后崩服 #249

@lwenk

Description

@lwenk

Describe the bug

HttpServer收到请求后,不能正确响应,后台报错
多次报错后,会崩服。

latest.log

minidump_2025-03-12_08-12-09.dmp
trace_2025-03-12_08-12-09.log

To Reproduce

const ADDRESS = "127.0.0.1"
const PORT = 5000
const http_server = {
    listen_address: ADDRESS || "127.0.0.1",
    listen_port: PORT || 5000,
    server: null,
    run: function () {
        this.server = new HttpServer();
        this.server.onGet("/test", (req, resp) => {
            resp.body = "hello world!"
            resp.status = 200;
            resp.reason = "OK";
        }).onGet("/404", (req, resp) => {
            resp.status = 404;
            resp.reason = "Not Found";
        }).onGet("/(.+)", (req, resp) => {
            resp.status = 404;
            resp.reason = "Not Found";
        }).onPreRouting((req, resp) => {
            logger.info(`onPreRouting [${req.method}] Path ${req.path}\n`, req.query, req.body)
        }).onPostRouting((req, resp) => {
        }).onError((req, resp) => {
        }).onException((req, resp, error) => {
            logger.error(error)
        }).listen(this.listen_address, this.listen_port);
        logger.info("http_server: run: Server listening on " + this.listen_address + ":" + this.listen_port);
    },
    stop: function () {
        this.server.stop();
        logger.info("http_server: stop: Server stopped");
    }
}
mc.listen("onServerStarted", () => {
    http_server.run()
})
  1. 启动服务器
  2. 请求http://127.0.0.1:5000/test
  3. 没有响应内容且控制台报错
  4. 多次报错后崩服

Expected behavior

能正常响应,正常返回内容

Screenshots

No response

Platform

Windows 11

BDS Version

1.21.60

LeviLamina Version

1.1.0

LegacyScriptEngine Version

0.10.0-rc.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions