-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: console log uncaught exceptions (#159)
sdk should stdout the exception before exit
- Loading branch information
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@hyperdx/instrumentation-exception': patch | ||
'@hyperdx/node-opentelemetry': patch | ||
--- | ||
|
||
fix: console log uncaught exceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const express = require('express'); | ||
const HyperDX = require('../build/src'); | ||
|
||
HyperDX.init({ | ||
apiKey: '', | ||
service: 'hard-crash', | ||
}); | ||
|
||
// Crash immediately | ||
har(); | ||
|
||
// unhandledRejection | ||
// new Promise((resolve, reject) => { | ||
// reject(new Error('🦄🦄🦄🦄')); | ||
// }); | ||
|
||
const PORT = parseInt(process.env.PORT || '7788'); | ||
const app = express(); | ||
|
||
app.get('/uncaught', async (req, res) => { | ||
setTimeout(() => { | ||
throw new Error('💥💥💥💥'); | ||
}, 2000); | ||
res.send('Uncaught exception in 2 seconds'); | ||
}); | ||
|
||
app.get('/crash', (req, res) => { | ||
throw new Error('🧨🧨🧨🧨'); | ||
}); | ||
|
||
app.get('/', (req, res) => { | ||
res.send('Hello World!'); | ||
}); | ||
|
||
// HyperDX.setupExpressErrorHandler(app); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Listening for requests on http://localhost:${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const express = require('express'); | ||
const Redis = require('redis'); | ||
const HyperDX = require('../build/src'); | ||
|
||
HyperDX.init({ | ||
apiKey: '', | ||
service: 'dummy_redis4', | ||
}); | ||
|
||
const PORT = parseInt(process.env.PORT || '7788'); | ||
const app = express(); | ||
|
||
app.use(express.json()); | ||
app.get('/', async (req, res) => { | ||
const client = await Redis.createClient({ | ||
host: 'localhost', | ||
port: 6379, | ||
}).connect(); | ||
// await redis.commandsExecutor('set', 'foo', 'bar'); | ||
await client.set('foo1', 'bar1'); | ||
await client.get('foo1'); | ||
// await redis.sendCommand(['SET', 'foo1', 'bar1']); | ||
// await redis.sendCommand(['GET', 'foo1']); | ||
// const [setKeyReply, otherKeyValue] = await client | ||
// .multi() | ||
// .set('key', 'value') | ||
// .get('another-key') | ||
// .exec(); // ['OK', 'another-value'] | ||
await client.disconnect(); | ||
res.send('Hello World!!!'); | ||
}); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Listening for requests on http://localhost:${PORT}`); | ||
}); |