0

今天我决定用 Raygun 试验做一些实验。在安装软件包和代理后,每次对我的服务提出请求时,我都会收到错误消息。

[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)

这是我的 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 是我正在尝试使用的。这是该js上的简单HTTP调用方法:

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;

如您所见,testSQL 是使用 GET 方法进行的简单调用。有任何想法吗?

4

1 回答 1

0

事实证明 MSSQL 查询产生了这个错误。Raygun 发布了一个新版本,并对其进行了更正。

于 2021-10-07T07:40:40.947 回答