Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. client
  5. resetWorker

spark.client.resetWorker

function resetWorker(): void

Terminate the global worker and reset all state.

Call this to clean up when you're done with the worker or want to restart fresh. The worker is automatically terminated when the page unloads.

After calling this, the next call to useSpark() will create a new worker.

Examples

// Terminate and clean up
resetWorker();

// Next useSpark() call will create a fresh worker
const s = useSpark(torch);
Previous
requestHotReload
Next
setWorkerScriptUrl