GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SDK fails in ESM mode in combination with openai · Issue #12414 · getsentry/sentry-javascript

SDK fails in ESM mode in combination with openai #12414

New issue
Copy link
New issue
Copy link
Closed
Closed
SDK fails in ESM mode in combination with openai#12414
Copy link
Assignees
timfish
Labels
BugPackage-Meta: OpenTelemetry
Milestone
v8 Instrumentation Issues

Description

@Xhale1
Xhale1
opened on Jun 7, 2024
Issue body actions

Is there an existing issue for this?

  • I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • I have reviewed the documentation https://docs.sentry.io/
  • I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.8.0

Framework Version

Node 20.14.0

Link to Sentry event

https://trainwell.sentry.io/issues/5463070600/?project=6067364&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=14d&stream_index=1

SDK Setup

Sentry.init({
  dsn: "[REDACTED]",
});

Steps to Reproduce

  1. Add openai package
  2. Instrument using instrumentation.js file
  3. Run with node --import ./dist/instrumentation.js dist/index.js

The addition of the following code is what triggers the issue:

import OpenAI from "openai";

const openAI = new OpenAI({
  apiKey: "[REDACTED]",
});

Expected Result

App builds with sentry instrumentation and no errors.

Actual Result

I receive the following error:

TypeError: API.Completions is not a constructor
    at new OpenAI (file:///[REDACTED]/node_modules/.pnpm/[email protected]/node_modules/openai/index.mjs:46:28)
    at file:///[REDACTED]
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

This might be related to #12237 however it appears to be a unique issue unrelated to initialization.

Reacted by Hudo Assenco, Danilo Fuchs, Nato Boram and Sergio Moreno

Activity

Next
  1. Xhale1
    added
    Type: Bug
    on Jun 7, 2024
  2. getsantry
    added
    Waiting for: Product Owner
    on Jun 7, 2024
  3. getsantry
    added this to GitHub Issues with 👀 3on Jun 7, 2024
  4. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 7, 2024
  5. github-actions
    added
    Package: node
    on Jun 7, 2024
  6. Lms24 commented on Jun 10, 2024

    @Lms24
    Lms24
    on Jun 10, 2024
    Member
    More actions

    Hey @Xhale1 thanks for reporting!

    Just to rule something out: Which version of openai are you using? It seems there were related issues in an older version. Thanks!

  7. getsantry
    removed
    Waiting for: Product Owner
    on Jun 10, 2024
  8. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 10, 2024
  9. AbhiPrasad
    added this to the v8 Instrumentation Issues milestone on Jun 10, 2024
  10. hudovisk commented on Jun 10, 2024

    @hudovisk
    hudovisk
    on Jun 10, 2024
    More actions

    Same issue here, using openai: 4.47.3

    "openai": "^4.47.3",
    
  11. getsantry
    added
    Waiting for: Product Owner
    on Jun 10, 2024
  12. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 10, 2024
  13. Xhale1 commented on Jun 10, 2024

    @Xhale1
    Xhale1
    on Jun 10, 2024
    Author
    More actions

    Thanks for checking in! Just confirmed that my issue exists with version 4.49.1 which appears to be the latest offered by openai.

    Let me know if a reproduction repo would help

  14. Lms24 commented on Jun 10, 2024

    @Lms24
    Lms24
    on Jun 10, 2024
    Member
    More actions

    A reproduction would be greatly appreciated, thanks :)

  15. getsantry
    removed
    Waiting for: Product Owner
    on Jun 10, 2024
  16. 80 remaining items

  17. mydea
    added a commit that references this issue on Sep 10, 2024

    fix: incorrect property name in `CHANGELOG.md` (#13635)

    0c0c7f6
  18. Xhale1 commented on Oct 17, 2024

    @Xhale1
    Xhale1
    on Oct 17, 2024
    Author
    More actions

    Hello! I'm sorry for not closing the loop here earlier.

    Using the onlyIncludeInstrumentedModules option is working great and has solved the original issue! I'm also happy to report my team has fully migrated to v8 thanks to this option 🎉

    I'll leave this issue open on the oft chance @timfish wants to use it to track openai compatibility without this option, but feel free to close whenever you see fit :)

    Thank you everyone for your dedication to this issue and to the larger open source community :)

    Reacted by Luca Forstner and Torick Davis
  19. getsantry
    added
    Waiting for: Product Owner
    on Oct 17, 2024
  20. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 17, 2024
  21. chargome
    removed
    Waiting for: Product Owner
    on Oct 18, 2024
  22. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 18, 2024
  23. Ivan-juni commented on Nov 15, 2024

    @Ivan-juni
    Ivan-juni
    on Nov 15, 2024
    More actions

    How can i use onlyIncludeInstrumentedModules with the late initialization (preload)?

  24. getsantry
    added
    Waiting for: Product Owner
    on Nov 15, 2024
  25. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 15, 2024
  26. andreiborza commented on Nov 18, 2024

    @andreiborza
    andreiborza
    on Nov 18, 2024
    Member
    More actions

    @Ivan-juni you currently can't but we could provide that option via an env variable. I added this to our backlog: #14330

  27. getsantry
    removed
    Waiting for: Product Owner
    on Nov 18, 2024
  28. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 18, 2024
  29. timfish commented on Feb 21, 2025

    @timfish
    timfish
    on Feb 21, 2025
    Collaborator
    More actions

    For v9 of the SDKs, the onlyIncludeInstrumentedModules option has been removed because this mode is now enabled by default. The incompatibility with openai should no longer exist.

    Reacted by Lukas Stracke
  30. timfish
    closed this as completedon Feb 21, 2025
  31. ghost added
    Bug
    on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @timfish
    timfish

Labels

BugPackage-Meta: OpenTelemetry

Projects

  • GitHub Issues with 👀 3
    Status
    No status
    Show more project fields

Milestone

  • v8 Instrumentation Issues

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.