unjs / unjs/ofetch

Attempting to use Datadog RUM with Nuxt in plugin, but fetch is already aliased before RUM can overwrite it.

Open
#339 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.4k
Forks
195
PR merge metrics
No merged PRs in 30d

Description

Environment
"@datadog/browser-rum": "^5.0.0",
"nuxt": "^3.7.4",
Reproduction

Not sure if I can set up an example as this might be a paid product only.

Describe the bug

I have the integration set up as a Nuxt plugin, and datadog attempts to override window.fetch, but at that point, fetch has already been stored as the original function in ofetch, so none of the callbacks get intercepted with appropriate headers. I don't see a manual way to override fetch after the fact. Is there a way to override this fetch in Nuxt?

Additional context

No response

Logs

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading ofetch's fetch initialization and the linked Datadog fetch instrumentation to understand when window.fetch is captured and overwritten. The issue is done when the Nuxt/plugin integration has a documented or supported way to ensure Datadog RUM intercepts requests with its headers, backed by a demonstrated reproduction or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
api, tooling, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.