Skip to main content

start

Function start 

Source
pub unsafe fn start(
    cx: *mut JSContext,
    promise_val: Value,
    profile: Option<StealthProfile>,
    method: Method,
    url: String,
    headers: Vec<(String, String)>,
    body: Option<Vec<u8>>,
)
Expand description

Schedule an async fetch via AsyncHTTP::init + HTTPThread::schedule. The caller must have already created the pending Promise via JS::NewPromiseObject(cx, null), pass it here as promise_val (an Object JSVal), and then set args.rval() to the same value before returning from the extern-C trampoline.

This function:

  1. Heap-roots the Promise value (GUARD-A: SM GC safety across ticks).
  2. Creates AsyncHTTP::init with TLS fingerprint injection.
  3. Schedules via HTTPThread::schedule (single epoll thread, O(1) OS threads).
  4. ref_concurrently on the event loop (keepalive while fetch is in flight).
  5. Pushes a PendingFetch onto the JS-thread registry.

§Safety

  • cx must be a live JSContext* on the current thread.
  • promise_val must be an Object JSVal holding a pending Promise.