Onurhan Demir

Thoughts

Short notes. Quotes, ideas, snippets.

Code·

// Context isolation fix in RSC tracing
// enterWith() was causing user data to leak between parallel renders
// run() isolates each execution and prevents silent corruption

asyncLocalStorage.run(newContext, () => {
  renderReactServerComponent();
});

A single line caused traces from User A to appear in User B's metrics. Replacing enterWith() with run() fixed it. The performance cost is worth it. In async-heavy environments, context isolation is survival, not optional.

The key difference: enterWith() modifies the current context and persists through all subsequent async operations, while run() creates a new isolated context that only exists within the callback. This prevents context bleeding where data from one request contaminates another.

read enterWith() document