Skip to content

v8::Object::CreationContext is deprecated #193

Description

@targos

See v8/v8@b38bf5b.

The new API returns a MaybeLocal. IIUC, it's up to us to handle the case when it's empty (for example throw an error).

Activity

  1. targos commented on Feb 20, 2021

    @targos
    MemberAuthor

    Here are all the warnings:

    
    [1961/3110] CXX obj/src/api/libnode.callback.o
    ../../src/api/callback.cc: In function ‘v8::MaybeLocal<v8::Value> node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::String>, int, v8::Local<v8::Value>*, node::async_context)’:
    ../../src/api/callback.cc:226:68: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Environment* env = Environment::GetCurrent(recv->CreationContext());
                                                                        ^
    In file included from ../../src/node.h:63,
                     from ../../src/api/callback.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/api/callback.cc: In function ‘v8::MaybeLocal<v8::Value> node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context)’:
    ../../src/api/callback.cc:255:72: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Environment* env = Environment::GetCurrent(callback->CreationContext());
                                                                            ^
    In file included from ../../src/node.h:63,
                     from ../../src/api/callback.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/api/callback.cc: In function ‘v8::MaybeLocal<v8::Value> node::MakeSyncCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’:
    ../../src/api/callback.cc:277:72: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Environment* env = Environment::GetCurrent(callback->CreationContext());
                                                                            ^
    In file included from ../../src/node.h:63,
                     from ../../src/api/callback.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    [1978/3110] CXX obj/src/libnode.async_wrap.o
    ../../src/async_wrap.cc: In function ‘void node::FastPromiseHook(v8::PromiseHookType, v8::Local<v8::Promise>, v8::Local<v8::Value>)’:
    ../../src/async_wrap.cc:301:53: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Local<Context> context = promise->CreationContext();
                                                         ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/memory_tracker.h:5,
                     from ../../src/base_object.h:28,
                     from ../../src/async_wrap.h:27,
                     from ../../src/async_wrap.cc:22:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/async_wrap.cc: In function ‘void node::FullPromiseHook(v8::PromiseHookType, v8::Local<v8::Promise>, v8::Local<v8::Value>)’:
    ../../src/async_wrap.cc:360:53: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Local<Context> context = promise->CreationContext();
                                                         ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/memory_tracker.h:5,
                     from ../../src/base_object.h:28,
                     from ../../src/async_wrap.h:27,
                     from ../../src/async_wrap.cc:22:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    [1989/3110] CXX obj/src/libnode.module_wrap.o
    ../../src/module_wrap.cc: In member function ‘v8::Local<v8::Context> node::loader::ModuleWrap::context() const’:
    ../../src/module_wrap.cc:86:44: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       return obj.As<Object>()->CreationContext();
                                                ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/memory_tracker.h:5,
                     from ../../src/base_object.h:28,
                     from ../../src/module_wrap.h:9,
                     from ../../src/module_wrap.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/module_wrap.cc: In static member function ‘static void node::loader::ModuleWrap::New(const v8::FunctionCallbackInfo<v8::Value>&)’:
    ../../src/module_wrap.cc:125:37: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
         context = that->CreationContext();
                                         ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/memory_tracker.h:5,
                     from ../../src/base_object.h:28,
                     from ../../src/module_wrap.h:9,
                     from ../../src/module_wrap.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    [2017/3110] CXX obj/src/libnode.node_messaging.o
    ../../src/node_messaging.cc: In member function ‘void node::worker::MessagePort::OnMessage()’:
    ../../src/node_messaging.cc:703:70: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Local<Context> context = object(env()->isolate())->CreationContext();
                                                                          ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/env.h:27,
                     from ../../src/node_messaging.h:6,
                     from ../../src/node_messaging.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/node_messaging.cc: In member function ‘v8::Maybe<bool> node::worker::MessagePort::PostMessage(node::Environment*, v8::Local<v8::Value>, const TransferList&)’:
    ../../src/node_messaging.cc:814:49: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Local<Context> context = obj->CreationContext();
                                                     ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/env.h:27,
                     from ../../src/node_messaging.h:6,
                     from ../../src/node_messaging.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/node_messaging.cc: In static member function ‘static void node::worker::MessagePort::PostMessage(const v8::FunctionCallbackInfo<v8::Value>&)’:
    ../../src/node_messaging.cc:912:49: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Local<Context> context = obj->CreationContext();
                                                     ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/env.h:27,
                     from ../../src/node_messaging.h:6,
                     from ../../src/node_messaging.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/node_messaging.cc: In static member function ‘static void node::worker::MessagePort::ReceiveMessage(const v8::FunctionCallbackInfo<v8::Value>&)’:
    ../../src/node_messaging.cc:1021:60: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
           port->ReceiveMessage(port->object()->CreationContext(), false);
                                                                ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/env.h:27,
                     from ../../src/node_messaging.h:6,
                     from ../../src/node_messaging.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    ../../src/node_messaging.cc: In function ‘void node::worker::{anonymous}::MessageChannel(const v8::FunctionCallbackInfo<v8::Value>&)’:
    ../../src/node_messaging.cc:1380:57: warning: ‘v8::Local<v8::Context> v8::Object::CreationContext()’ is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
       Local<Context> context = args.This()->CreationContext();
                                                             ^
    In file included from ../../src/util.h:27,
                     from ../../src/util-inl.h:29,
                     from ../../src/aliased_buffer.h:8,
                     from ../../src/env.h:27,
                     from ../../src/node_messaging.h:6,
                     from ../../src/node_messaging.cc:1:
    ../../deps/v8/include/v8.h:4228:18: note: declared here
       Local<Context> CreationContext();
                      ^~~~~~~~~~~~~~~
    
  2. targos commented on Feb 28, 2021

    @targos
    MemberAuthor

    @addaleax what do you think we should do?

  3. devsnek commented on Feb 28, 2021

    @devsnek
    Member

    For our purposes GetCreationContext().ToLocalChecked() should be fine. Inside V8 GetCreationContext().ToHandleChecked() is used a lot too.

  4. targos commented on Feb 28, 2021

    @targos
    MemberAuthor

    Okay, I did that in nodejs/node@5db39ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo