Skip to content

Fix flawed empty body optimization test #80

@VikramAditya33

Description

@VikramAditya33

The test "should optimize empty bodies by using the exact same memory reference" creates two separate UwsRequest instances but onDataCallback is a module-level variable that gets overwritten by each _initBodyParser call.

When req2._initBodyParser() is called, it overwrites the callback set by req1, so only req2 actually receives the empty data. The test passes because both requests end up returning the shared EMPTY_FROZEN_OBJECT sentinel, but not for the intended reason.

The test should verify that calling json() multiple times on the same request returns the cached result, not that two different requests return the same sentinel.

Where: src/http/core/request.spec.ts around line 450

The test should use a single request and call json() twice to verify caching works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerstesta fix around any test

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions