title: Fatal error in v8::HandleScope::CreateHandle() # Cannot create a handle without a HandleScope
body: <p>I am writing a .cc file so that I can read functions from it in a .js file.</p>
  <p>The structure of code is as follows:</p>
  <pre><code>napi_value createResult(napi_env env, string resultType, int64_t handlevalue) {
      napi_status status;
      napi_value ObjectRef, returnObject, errorObject;
  
      printf(&quot;INSIDE FUCNTION: PART1\n&quot;);
  
      // Creating NAPI Object's
      status = napi_create_object(env, &amp;ObjectRef);
  
      std::cout&lt;&lt;&quot;status=&quot;&lt;&lt;status&lt;&lt;std::endl;
  
      assert(status == napi_ok);
  
  
      printf(&quot;INSIDE FUCNTION: PART2\n&quot;);
  
      status = napi_create_object(env, &amp;errorObject);
      assert(status == napi_ok);
  
      printf(&quot;INSIDE FUCNTION: PART3\n&quot;);
  
      status = napi_create_object(env, &amp;returnObject);
      assert(status == napi_ok);
  
      printf(&quot;INSIDE FUCNTION: PART4\n&quot;);
  
      const char* resultTypeChar = resultType.c_str();
      status = napi_set_named_property(env, returnObject, &amp;resultTypeChar[0], ObjectRef);
      assert(status == napi_ok);
  
      printf(&quot;INSIDE FUCNTION: PART5\n&quot;);
  
      return returnObject;
  }
  
  void ABC(napi_env env, void* data){
  
      // some code....
      size_t handlevalue = access._handle;
  
      obj-&gt;result = createResult(env,&quot;access&quot;,handlevalue);
  
      obj-&gt;async_action_status = 0;
    }
  }
  
  napi_value f1(napi_env env,
    napi_callback_info info) {
    //
    napi_value promise;
    napi_status status;
    // some code....
  
    napi_value resource_name;
    napi_create_string_utf8(env, &quot;f1&quot;, NAPI_AUTO_LENGTH, &amp;resource_name);
  
    napi_create_async_work(env, NULL, resource_name, ABC, DEF, obj, &amp;obj-&gt;work);
  
    napi_queue_async_work(env, obj-&gt;work);
  
    return promise;
  }
  </code></pre>
  <p>On compiling this &amp; then running a .js file, the following error is displayed:</p>
  <pre><code>INSIDE FUCNTION: PART1
  
  #
  # Fatal error in v8::HandleScope::CreateHandle()
  # Cannot create a handle without a HandleScope
  #
  
  Illegal instruction (core dumped)
  
  </code></pre>
  <p>I have not used any <code>v8</code> or <code>HandleScope</code> or <code>CreateHandle</code> function anywhere in my code.</p>
  <p>Since I am new to all this stuff of <code>promise</code> and <code>async</code>, so I am clueless about how to resolve this.</p>
  <p>Kindly help</p>