File tree 1 file changed +8
-1
lines changed
packages/node/src/integrations
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -195,10 +195,17 @@ function getAppContext(): AppContext {
195
195
export function getDeviceContext ( deviceOpt : DeviceContextOptions | true ) : DeviceContext {
196
196
const device : DeviceContext = { } ;
197
197
198
+ // Sometimes os.uptime() throws due to lacking permissions: https://github.com/getsentry/sentry-javascript/issues/8202
199
+ let uptime ;
200
+ try {
201
+ uptime = os . uptime && os . uptime ( ) ;
202
+ } catch ( e ) {
203
+ // noop
204
+ }
205
+
198
206
// os.uptime or its return value seem to be undefined in certain environments (e.g. Azure functions).
199
207
// Hence, we only set boot time, if we get a valid uptime value.
200
208
// @see https://github.com/getsentry/sentry-javascript/issues/5856
201
- const uptime = os . uptime && os . uptime ( ) ;
202
209
if ( typeof uptime === 'number' ) {
203
210
device . boot_time = new Date ( Date . now ( ) - uptime * 1000 ) . toISOString ( ) ;
204
211
}
You can’t perform that action at this time.
0 commit comments