Error: Maximum call stack
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.7k
- Forks
- 1.9k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 5
Description
Hello. I generate C++ code using a JS script. In place of "codeChars" I insert a very large array which represents the JS code. This code is run further by the function "napi_run_script". The problem is that if there are a lot of hardcoded symbols, something more than 200,000+, the addon compiles normally, but when connected it does not work and causes an error. In nodes I get an error - Maximum call stack size.
#include <node_api.h>
#include <stdlib.h>
namespace lib_${nameLib}
{
static napi_value Method(napi_env env, napi_callback_info info) {
napi_value rslt_run, str_jscode;
int arr[] = {${codeChars}};
int lenArr = sizeof(arr)/sizeof(int);
char* jscode = new char[lenArr];
for (int i = 0; i < lenArr; i++) {
jscode[i] = arr[i];
}
napi_status status = napi_create_string_utf8(env, jscode, NAPI_AUTO_LENGTH, &str_jscode);
delete[] jscode;
if (status != napi_ok) {
const char* message = "Error: status != napi_ok";
napi_throw_error(env, NULL, message);
return NULL;
}
napi_run_script(env, str_jscode, &rslt_run);
return rslt_run;
}
static napi_value Init(napi_env env, napi_value exports) {
return Method(env, NULL);
}
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init);
}
Please tell me how can I fix this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated addon entry point Method and the napi_run_script call, then reproduce the failure with an array exceeding 200,000 symbols. Compare the generated C++ and Node error to determine whether the problem belongs to node-gyp or the runtime; done means identifying a reproducible cause and a scoped fix or documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, javascript, node.js
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100