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-6/

Event-Driven Request Monitor

Create a small utility that performs an HTTP GET against a provided URL while exposing event-driven lifecycle hooks for observers. It should let callers attach multiple callbacks to key request stages, remove them when no longer needed, and emit a custom completion signal with summary data once the response arrives.

Capabilities

Lifecycle listeners

  • When start is invoked, two callbacks registered for the "start" stage both run before any response data is returned, and the call resolves with the full response text. @test

Listener removal

  • If a listener is unsubscribed before completion, it never runs, while other callbacks for the same stage still fire in registration order. @test

Completion broadcast

  • After a successful response, a custom "completed" event is emitted to subscribed handlers carrying the final status code and body length. @test

Abort handling

  • When the request is aborted mid-flight, abort-stage listeners run and the completion event is not emitted. @test

Implementation

@generates

API

export type RequestEvent = { type: string; data?: any };

export interface RequestMonitor {
  start(): Promise<string>;
  abort(): void;
  on(eventName: string, handler: (event: RequestEvent) => void): void;
  off(eventName: string, handler: (event: RequestEvent) => void): void;
  trigger(eventName: string, data?: any): void;
}

export function createRequestMonitor(
  url: string,
  options?: { headers?: Record<string, string> }
): RequestMonitor;

Dependencies { .dependencies }

xmlhttprequest { .dependency }

Provides a browser-style HTTP request object whose event system powers the monitor's lifecycle hooks.

Version

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