Skip to content

Unexpected closing brace error from import-in-the-middle #12807

Closed
@FozzieHi

Description

@FozzieHi

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.15.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup/Reproduction Example

No response

Steps to Reproduce

Branching off this issue, when running import-in-the-middle v1.8.1, I'm getting the following error:

Error: 'import-in-the-middle' failed to wrap 'file:///app/node_modules/zlib-sync/index.js'
    at getSource (/app/node_modules/import-in-the-middle/hook.js:304:21)
    at async load (/app/node_modules/import-in-the-middle/hook.js:319:26)
    at async nextLoad (node:internal/modules/esm/hooks:866:22)
    at async Hooks.load (node:internal/modules/esm/hooks:449:20)
    at async handleMessage (node:internal/modules/esm/worker:196:18) {
  cause: Error: Unexpected closing brace.
    at @:4:142
      at parseSource (/app/node_modules/cjs-module-lexer/lexer.js:185:17)
      at parseCJS (/app/node_modules/cjs-module-lexer/lexer.js:43:5)
      at getCjsExports (/app/node_modules/import-in-the-middle/lib/get-exports.js:37:20)
      at getExports (/app/node_modules/import-in-the-middle/lib/get-exports.js:100:12)
      at async /app/node_modules/import-in-the-middle/lib/get-exports.js:48:28
      at async Promise.all (index 0)
      at async getCjsExports (/app/node_modules/import-in-the-middle/lib/get-exports.js:40:5)
      at async processModule (/app/node_modules/import-in-the-middle/hook.js:131:23)
      at async getSource (/app/node_modules/import-in-the-middle/hook.js:269:25)
      at async load (/app/node_modules/import-in-the-middle/hook.js:319:26) {
    loc: 973
  }
}

This causes this from discord.js:

WebSocketShard: Compression is enabled but zlib-sync is not installed, falling back to identify compress

It still occurs with import-in-the-middle v1.9.0, but as a warning, this is the output with --trace-warnings enabled:

WebSocketShard: Compression is enabled but zlib-sync is not installed, falling back to identify compress
(node:1) Warning: Error: 'import-in-the-middle' failed to wrap 'file:///app/node_modules/zlib-sync/index.js'
    at getSource (/app/node_modules/import-in-the-middle/hook.js:366:21)
    at async load (/app/node_modules/import-in-the-middle/hook.js:381:26)
    ... 2 lines matching cause stack trace ...
    at async handleMessage (node:internal/modules/esm/worker:196:18) {
  cause: Error: Failed to parse 'file:///app/node_modules/zlib-sync/index.js'
      at getExports (/app/node_modules/import-in-the-middle/lib/get-exports.js:118:17)
      at async processModule (/app/node_modules/import-in-the-middle/hook.js:172:23)
      ... 3 lines matching cause stack trace ...
      at async Hooks.load (node:internal/modules/esm/hooks:449:20)
      at async handleMessage (node:internal/modules/esm/worker:196:18) {
    cause: Error: Failed to parse 'file:///app/node_modules/zlib-sync/build/Release/zlib_sync.node'
        at getExports (/app/node_modules/import-in-the-middle/lib/get-exports.js:118:17)
        at async /app/node_modules/import-in-the-middle/lib/get-exports.js:51:28
        ... 4 lines matching cause stack trace ...
        at async getSource (/app/node_modules/import-in-the-middle/hook.js:331:25)
        at async load (/app/node_modules/import-in-the-middle/hook.js:381:26)
        at async nextLoad (node:internal/modules/esm/hooks:866:22)
        at async Hooks.load (node:internal/modules/esm/hooks:449:20) {
      cause: [Error]
    }
  }
}
    at emitWarning (/app/node_modules/import-in-the-middle/hook.js:156:11)
    at getSource (/app/node_modules/import-in-the-middle/hook.js:368:9)
    at async load (/app/node_modules/import-in-the-middle/hook.js:381:26)
    at async nextLoad (node:internal/modules/esm/hooks:866:22)
    at async Hooks.load (node:internal/modules/esm/hooks:449:20)
    at async handleMessage (node:internal/modules/esm/worker:196:18)

Expected Result

N/A

Actual Result

N/A

Metadata

Metadata

Assignees

Type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions