CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-xmlhttprequest

tessl install tessl/npm-xmlhttprequest@1.8.0

XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object

Agent Success

Agent success rate when using this tile

75%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.15x

Baseline

Agent success rate without this tile

65%

task.mdevals/scenario-4/

Request Lifecycle Tracker

Implement an async HTTP helper that relies on the dependency's lifecycle notifications to expose how a request progresses from start to completion.

Capabilities

Records lifecycle transitions

  • For an async GET to http://localhost:4000/ping that responds with status 200 and body "pong", capture each state code from the first transition after starting the request through completion in order [1, 2, 3, 4], and include that log in the resolved result. @test

Emits state-change notifications

  • When a callback is provided, call it on every state change with the latest numeric state and the cumulative state log; a successful GET triggers four callbacks. @test

Completion-driven result

  • Resolve the returned promise only when the completion notification fires, and return an object containing status (200), body ("pong"), and the full state log; do not resolve on intermediate state changes. @test

Abort halts lifecycle

  • If an abort is triggered after the request has started but before completion, stop further lifecycle notifications, reject with the states recorded so far, and return no body text. @test

Implementation

@generates

API

/**
 * Starts an async HTTP GET request to the given URL.
 * @param {string} url
 * @param {(state: number, log: number[]) => void} [onStateChange] optional observer for lifecycle transitions
 * @returns {Promise<{ status: number, body: string, states: number[] }>} resolves when the request finishes, rejects if aborted
 */
export function trackLifecycle(url, onStateChange);

/**
 * Aborts the in-flight request started by trackLifecycle, if any.
 */
export function abortActive();

Dependencies { .dependencies }

xmlhttprequest { .dependency }

Use the dependency-provided evented HTTP client to drive lifecycle tracking.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/xmlhttprequest@1.8.x
tile.json