Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
uurien committed Dec 16, 2024
1 parent afe2591 commit 8ca6569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ const ddTraceDir = path.join(currentUrl.pathname, '..', '..', '..', '..', '..',
let idCounter = 1
let initialized = false


let port, entryPoint
let port

export async function initialize (data) {
if (initialized) return Promise.reject(new Error('ALREADY INITIALIZED'))
initialized = true

port = data.port2
entryPoint = data.entryPoint
}

export async function load(url, context, nextLoad) {
console.log('load?', url)
export async function load (url, context, nextLoad) {
const result = await nextLoad(url, context)

if (!port) return result
Expand Down
9 changes: 5 additions & 4 deletions packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Module = require('module')
const { pathToFileURL } = require('url')
const { MessageChannel } = require('worker_threads');
const { MessageChannel } = require('worker_threads')
const shimmer = require('../../../../../datadog-shimmer')
const { isPrivateModule, isNotLibraryFile } = require('./filter')
const { csiMethods } = require('./csi-methods')
Expand All @@ -17,6 +17,7 @@ const hardcodedSecretCh = dc.channel('datadog:secrets:result')
let rewriter
let getPrepareStackTrace
let kSymbolPrepareStackTrace
let esmRewriterEnabled = false

let getRewriterOriginalPathAndLineFromSourceMap = function (path, line, column) {
return { path, line, column }
Expand Down Expand Up @@ -146,8 +147,9 @@ function enableRewriter (telemetryVerbosity) {
}

function enableEsmRewriter () {
if (isMainThread && Module.register) {
const { port1, port2 } = new MessageChannel();
if (isMainThread && Module.register && !esmRewriterEnabled) {
esmRewriterEnabled = true
const { port1, port2 } = new MessageChannel()
port1.on('message', (message) => {
message.source = rewriteForESM(message.source, message.url)
port1.postMessage(message)
Expand All @@ -162,7 +164,6 @@ function enableEsmRewriter () {
transferList: [port2]
})
} catch (e) {
console.error('e.message', e.message)
log.error('[ASM] Error enabling ESM Rewriter', e)
}
})
Expand Down

0 comments on commit 8ca6569

Please sign in to comment.