Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(node): Partially remove dynamic require calls #7377

Merged
merged 6 commits into from Mar 8, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 8, 2023

This PR removes a few dynamic require calls from our Node SDK in favour of making them top-level imports.

  • Http integration: http and https are now top-level imports.
  • Transport: https-proxy-agent is now a top-level import as v5 no longer produces side effects when importing.

We need this change for the SvelteKit SDK, as SvelteKit doesn't accept require calls in server code by default.

ref #7348 #6692

@Lms24 Lms24 force-pushed the lms/remove-dynamic-requires branch from b24e5d5 to d239f13 Compare March 8, 2023 12:08
this._session.post('Debugger.enable');
// We only want to pause on uncaught exceptions
this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
this._inspectorModulePromise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems more elegant/"safe" than throwing in the constructor anyhow to me 👍

@Lms24 Lms24 force-pushed the lms/remove-dynamic-requires branch from d076231 to ef38b72 Compare March 8, 2023 14:24
@Lms24 Lms24 marked this pull request as ready for review March 8, 2023 14:54
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, this is actually much better!

@Lms24 Lms24 changed the title ref(node): Remove require calls ref(node): Partially remove require calls Mar 8, 2023
@Lms24 Lms24 changed the title ref(node): Partially remove require calls ref(node): Partially remove dynamic require calls Mar 8, 2023
@Lms24 Lms24 merged commit 17f31c6 into develop Mar 8, 2023
@Lms24 Lms24 deleted the lms/remove-dynamic-requires branch March 8, 2023 15:21
@Lms24 Lms24 self-assigned this Mar 10, 2023
Lms24 added a commit that referenced this pull request Mar 13, 2023
…7430)

Partially revert #7377 which caused monkey patching errors when patching the native `http` and `https` modules in the Node SDK (#7425). Similarly, also our Serverless SDK was subjected to the same problem (#7421). 

The problem is that `import` doesn't permit monkey patching of the imported (`http(s)`) module, producing this error:

```bash
TypeError: Cannot assign to read only property 'get' of object '[object Module]'
```

I tried using a dynamic import instead but got the same result. So it seems like we can only use `require` here :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants