Trying ICMP npm package in Netlify Functions -- it fails

Site: sleepy-hamilton-830aa9.netlify.app
No DNS or build problems.

I tried building a Netlify function that test pinging an IP.
This is just a test, not for prod.

I get the error below when I try using the icmp package (GitHub - quantumsheep/node-icmp: Internet Control Message Protocol in Node).

I suppose that it’s because ICMP is not supported in the scope of Netlify Functions, so if anyone has any idea to confirm this suspicion or any other explanation, I’d appreciate it.

12:36:12 AM 2022-01-21T03:36:12.215Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"/lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","code":"ERR_DLOPEN_FAILED","stack":["Error: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:93:18)","    at Object.<anonymous> (/var/task/node_modules/raw-socket/index.js:4:11)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)"]}
12:36:12 AM 2022-01-21T03:36:12.462Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"/lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","code":"ERR_DLOPEN_FAILED","stack":["Error: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:93:18)","    at Object.<anonymous> (/var/task/node_modules/raw-socket/index.js:4:11)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)"]}
12:36:12 AM 13708f5e Duration: 201.57 ms	Memory Usage: 12 MB
12:36:12 AM Unknown application error occurred
Error
12:36:14 AM 2022-01-21T03:36:14.365Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"/lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","code":"ERR_DLOPEN_FAILED","stack":["Error: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:93:18)","    at Object.<anonymous> (/var/task/node_modules/raw-socket/index.js:4:11)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)"]}
12:36:14 AM cf0b7741 Duration: 196.43 ms	Memory Usage: 12 MB
12:36:14 AM Unknown application error occurred
Error
12:36:14 AM 2022-01-21T03:36:14.585Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"/lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","code":"ERR_DLOPEN_FAILED","stack":["Error: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/node_modules/raw-socket/build/Release/raw.node)","    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:93:18)","    at Object.<anonymous> (/var/task/node_modules/raw-socket/index.js:4:11)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)"]}```

Function code:

const ICMP = require('icmp')
const querystring = require("querystring");

exports.handler = async (event, context) => {
  // Only allow POST
  if (event.httpMethod !== "POST") {
    return { statusCode: 405, body: "Method Not Allowed" };
  }

  // When the method is POST, the name will no longer be in the event’s
  // queryStringParameters – it’ll be in the event body encoded as a query string
  const params = querystring.parse(event.body);

  const retu = icmp.ping(params.ip, 2000)

  return {
    statusCode: 200,
    body: retu
  };
};

Hi @andresf91,

This might be relevant:

1 Like

Thanks for your reply.
This closes my question.