Skip to content

Commit

Permalink
chore: reverted test & dns = eval('require("dns")')
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Nov 15, 2024
1 parent c8957e5 commit 08fad96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default (testContext: { getAgent: () => ConfiguredAgent; setup: () => Pro
it('should lookup the location of a hostname', async () => {
await expect(
agent.lookupLocation({
ipOrHostname: 'localhost',
ipOrHostname: 'sphereon.com',
}),
).resolves.toEqual({
continent: 'EU',
Expand Down
7 changes: 4 additions & 3 deletions packages/anomaly-detection/src/agent/AnomalyDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ export class AnomalyDetection implements IAgentPlugin {
// Fallback to Node.js dns
let dns
try {
dns = await Function('return import("dns")')()
} catch {
dns = eval('require("dns")')
} catch (e) {
console.error(e)
throw new Error(
'DNS resolution not available on this platform, use the dnsLookupCallback in the AnomalyDetection constructor to implement DNS resolution for your platform.',
`DNS resolution not available on this platform, use the dnsLookupCallback in the AnomalyDetection constructor to implement DNS resolution for your platform.\r\n${e.message}`,
)
}

Expand Down

0 comments on commit 08fad96

Please sign in to comment.