Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whistle.script 加载脚本容易出现超时 #27

Open
youfak opened this issue Mar 26, 2023 · 2 comments
Open

whistle.script 加载脚本容易出现超时 #27

youfak opened this issue Mar 26, 2023 · 2 comments

Comments

@youfak
Copy link

youfak commented Mar 26, 2023

Error: Script execution timed out after 600ms
at Script.runInContext (node:vm:141:12)
at execScript (/root/.WhistleAppData/custom_plugins/whistle.script/node_modules/whistle.script/lib/scripts.js:63:12)
at exports.getHandler (/root/.WhistleAppData/custom_plugins/whistle.script/node_modules/whistle.script/lib/scripts.js:94:10)
at module.exports (/root/.WhistleAppData/custom_plugins/whistle.script/node_modules/whistle.script/lib/auth.js:7:38)
at Server. (/usr/local/lib/node_modules/whistle/lib/plugins/load-plugin.js:1799:32)
at Server.emit (node:events:513:28)
at Server. (/usr/local/lib/node_modules/whistle/lib/plugins/load-plugin.js:2006:24)
at Server.emit (node:events:513:28)
at parserOnIncoming (node:_http_server:1072:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) {
code: 'ERR_SCRIPT_EXECUTION_TIMEOUT'
}

@avwo
Copy link
Member

avwo commented Mar 26, 2023

贴下你执行的代码

@youfak
Copy link
Author

youfak commented Mar 27, 2023

贴下你执行的代码

const CryptoJS = require('/usr/local/lib/node_modules/crypto-js');
const cache = require('/usr/local/lib/node_modules/memory-cache');
const request = require('/usr/local/lib/node_modules/request');
const url = require('url');
const querystring = require('querystring');

exports.handleRequest = async (ctx, request) => {
  // ctx.fullUrl 可以获取请求url
  // ctx.headers 可以获取请求头
  // ctx.options 里面包含一些特殊的请求头字段,分别可以获取一些额外信息,如请设置的规则等
  // ctx.method 获取和设置请求方法
  // ctx.req
  // ctx.res
  const { req, res, headers } = ctx;
  const client = request(async (svrRes) => {
    res.writeHead(svrRes.statusCode, svrRes.headers);
    svrRes.pipe(res);
  });
  req.pipe(client);

  let arg = url.parse(ctx.fullUrl).query;
  let param_query = querystring.parse(arg);
  let signature = param_query['signature'];
  let userid = param_query['userid'];
  let mid = param_query['mid'];
  let token = param_query['token'];
  let dfid = param_query['dfid'];
  let uuid = param_query['uuid'];
  let appid = param_query['appid'];
  let clientver = param_query['clientver'];
  let clienttime = param_query['clienttime'];

  if (
    userid &&
    signature &&
    mid &&
    token &&
    dfid &&
    uuid &&
    appid &&
    clientver &&
    clienttime
  ) {
   console.log("获取成功");
  }
};

我是通过打包docker镜像的方式运行 whistle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants