File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
packages/node/src/integrations Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -195,10 +195,17 @@ function getAppContext(): AppContext {
195195export function getDeviceContext ( deviceOpt : DeviceContextOptions | true ) : DeviceContext {
196196 const device : DeviceContext = { } ;
197197
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+
198206 // os.uptime or its return value seem to be undefined in certain environments (e.g. Azure functions).
199207 // Hence, we only set boot time, if we get a valid uptime value.
200208 // @see https://github.com/getsentry/sentry-javascript/issues/5856
201- const uptime = os . uptime && os . uptime ( ) ;
202209 if ( typeof uptime === 'number' ) {
203210 device . boot_time = new Date ( Date . now ( ) - uptime * 1000 ) . toISOString ( ) ;
204211 }
You can’t perform that action at this time.
0 commit comments