newrelic 9.7.3 → 9.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NEWS.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### v9.7.4 (2022-12-15)
2
+
3
+ * Fixed system info gathering to prevent unhandled promise rejection when an error occurs reading `/proc` information.
4
+
1
5
  ### v9.7.3 (2022-12-12)
2
6
 
3
7
  * Added support for Code Level Metrics on API methods: `startSegment`, `startBackgroundTransaction`, and `startWebTransaction`.
@@ -214,7 +214,7 @@ module.exports._getProcessorStats = async function getProcessorStats() {
214
214
 
215
215
  return processorStats
216
216
  } else if (platform.match(/linux/i)) {
217
- const data = await readProc('/proc/cpuinfo')
217
+ const data = await getProcInfo('/proc/cpuinfo')
218
218
 
219
219
  return parseCpuInfo(data)
220
220
  }
@@ -237,7 +237,7 @@ module.exports._getMemoryStats = async function getMemoryStats() {
237
237
  const memory = await getSysctlValue(['hw.realmem'])
238
238
  return parseInt(memory, 10) / (1024 * 1024)
239
239
  } else if (platform.match(/linux/i)) {
240
- const data = await readProc('/proc/meminfo')
240
+ const data = await getProcInfo('/proc/meminfo')
241
241
  return parseMemInfo(data)
242
242
  }
243
243
 
@@ -254,7 +254,7 @@ async function getKernelVersion() {
254
254
  if (platform.match(/darwin/i) || platform.match(/bsd/i)) {
255
255
  return await getSysctlValue(['kern.version'])
256
256
  } else if (platform.match(/linux/i)) {
257
- return await readProc('/proc/version')
257
+ return await getProcInfo('/proc/version')
258
258
  }
259
259
 
260
260
  logger.debug('Unknown platform: %s; could not read kernel version', platform)
@@ -294,3 +294,18 @@ async function getSysctlValue(names = []) {
294
294
 
295
295
  return returnValue
296
296
  }
297
+
298
+ /**
299
+ * Helper method for getting /proc/* file information in Linux environments
300
+ *
301
+ * @param {string} procPath - the proc file to read
302
+ * @returns {*} null if the lookup fails, otherwise the proc file information
303
+ */
304
+ async function getProcInfo(procPath) {
305
+ try {
306
+ return await readProc(procPath)
307
+ } catch (err) {
308
+ // swallow the error if reading fails, logging handled in readProc()
309
+ return null
310
+ }
311
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "9.7.3",
3
+ "version": "9.7.4",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [