Raygun TypeError [ERR_INVALID_ARG_TYPE]
Gombo Khorloo
Posted on
Oct 06 2021
Today I decided to do some experiments with the Raygun trial. And after installing the package and the agent I'm receiving errors every time a request has been made to my service.
[raygun-apm] Encountered an error building a trace:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at Function.from (buffer.js:333:9)
at Object.encodeUnicodeString (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile\buffer_helpers.js:25:33)
at Object.CT_SQL_INFORMATION (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile\wire_protocol\commands.js:114:26)
at Object.eventsToMessages (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile\messages.js:156:38)
at Object.<anonymous> (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile.js:60:37)
at Generator.next (<anonymous>)
at C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile.js:27:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile.js:23:12)
at Object.processProfile (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\process_profile.js:44:12)
at processProfiles (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\profiler.js:180:27)
at wakeProfileProcessor (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\profiler.js:199:9)
at C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\profiler.js:238:13
at Generator.next (<anonymous>)
at fulfilled (C:\Users\Gombo\OneDrive\Documents\Orchard Consulting LLC\WebService Development\sap-shopify\node_modules\raygun-apm\lib\src\profiler.js:40:32)
Here is my server.js
require('raygun-apm/http');
const express = require("express");
const dotenv = require("dotenv");
const cron = require("node-cron");
const bodyParser = require("body-parser");
require("body-parser-xml")(bodyParser);
const fulfillmentRouter = require("./routes/order/fulfillment");
const printRouter = require("./routes/order/print");
const invoiceRouter = require("./routes/order/invoice");
const shopifyRouter = require("./routes/order/shopifyOrder");
const rfidRouter = require("./routes/rfid/order");
const refundRouter = require("./cron/refund");
const payoutRouter = require("./cron/payout");
const timezoneRouter = require("./cron/timeUpdater");
const shipmentRouter = require("./routes/order/shipment");
const dhlExpressRouter = require("./routes/order/dhlExpress");
const errorHandler = require("./common/error");
dotenv.config();
const app = express();
app.use(
bodyParser.xml({
limit: "10mb",
})
);
app.use(
express.json({
limit: "10mb",
})
);
app.use("/shopify", shopifyRouter);
app.use("/order", fulfillmentRouter);
app.use("/label", printRouter);
app.use("/invoice", invoiceRouter);
app.use("/rfid", rfidRouter);
app.use("/shipment", shipmentRouter);
app.use("/dhl", dhlExpressRouter);
app.use(errorHandler);
cron.schedule("0 11 * * *", () => {
console.log("Refund Payment running...");
refundRouter.refundPayment();
});
cron.schedule("00 * * * *", () => {
console.log("Update DE Time");
timezoneRouter.updateDETime();
});
/*cron.schedule("0 9 * * *", () => {
console.log("Payout Payment running...");
payoutRouter.getPayouts();
});*/
const server = app.listen(process.env.PORT, console.log(`Server port ${process.env.PORT}`));
process.on("unhandledRejection", (err, promise) => {
console.log(`Error unhandledRejection : ${err.message}`);
// server.close(() => {
// process.exit(1);
// });
});
process.on("uncaughtException", function (ex) {
console.log(`Error uncaughtException : ${ex.message}`);
// server.close(() => {
// process.exit(1);
// });
});
process.once("SIGUSR2", function () {
process.kill(process.pid, "SIGUSR2");
});
shopifyRouter is the one I'm trying to use. Here is simple HTTP call method on that js:
const express = require("express");
const Shopify = require("shopify-api-node");
const stores = require("../../config/stores.json");
const companies = require("../../config/slCompany.json");
const router = express.Router();
const {
shopifyLogger,
testLogger
} = require("../../common/logger");
const sqlConnection = require("../../common/sqlConfig");
const moment = require('moment');
const sl = require("../../common/httpCall");
const fs = require('fs');
const request = require("request-promise");
let cookie = '';
let testDBCookie = '';
router.get("/testSQL", async function (req, res) {
try {
var options = {
method: "GET",
uri: "https://timezone.abstractapi.com/v1/current_time/?api_key=550fcc1c13aa4907bcad3ef24e6c611d",
json: true,
};
options.uri += "&location=Berlin, Germany";
let berlinDate = await request(options);
currentDate = berlinDate.datetime.substring(0, 10);
let deDate = await sqlConnection.getQuery("55555555", "SELECT U_O_Date1 AS 'Date' FROM [@O_DATE1] WHERE Name='Germany'");
console.log(currentDate == deDate.recordset[0].Date.toISOString().substring(0, 10));
return res.status(400).json({
msg: "Success"
});
} catch (error) {
console.log("Update DATE Exception:", "Germany", error);
return res.status(400).json({
msg: "Failure"
});
}
});
module.exports = router;
As you can testSQL is a simple call with GET method. Any ideas?
Deleted User
Raygun
Posted on
Oct 06 2021
Hi Gombo,
Thank you for reaching out to us.
We're currently investigation into your query and will reach back out shortly.
Kind regards, Hetvi
Deleted User
Raygun
Posted on
Oct 07 2021
Hi Gombo,
This turned out to be a problem with our mssql support, and occurred when not explicitly setting a database option on mssql.connect.
We've released version 1.4.1 which should solve the issue, please give that a try and let us know if the problem continues.
Kind regards,
Hetvi