You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have multiple instances of Duktape in-flight controlled via an external event loop (Mojo). When one instance of Duktape is waiting for an event to complete (ie, fetching data from the web) console output and errors are written to the wrong Duktape instance (looks like the last created).
I assume this is a valid use case? Other than console output/errors, everything else seems ok.
The following example will show the issue:
use warnings;
use strict;
use Data::Dumper;
use JavaScript::Duktape::XS;
my $options = {
gather_stats => 1,
save_messages => 1,
};
my $instanceOne = JavaScript::Duktape::XS->new($options);
my $instanceTwo = JavaScript::Duktape::XS->new($options);
$instanceOne->eval('console.log("hello from instance one")');
print "output from instance one: \n";
print Dumper $instanceOne->get_msgs();
print "output from instance two: \n";
print Dumper $instanceTwo->get_msgs();
When run, the output will be shown for $instanceTwo rather than $instanceOne that ran the code.
As it's a global and not on an object basis, it's causing the problem. I think the solution would be to associate a pointer from the perl side (ie, Duk*) into the actual duktape (ie, ctx*) and remove the global struct above.
Thoughts?
Regards,
The text was updated successfully, but these errors were encountered:
All,
I have multiple instances of Duktape in-flight controlled via an external event loop (Mojo). When one instance of Duktape is waiting for an event to complete (ie, fetching data from the web) console output and errors are written to the wrong Duktape instance (looks like the last created).
I assume this is a valid use case? Other than console output/errors, everything else seems ok.
The following example will show the issue:
When run, the output will be shown for $instanceTwo rather than $instanceOne that ran the code.
I believe the problem is with
In duk_Console.c
As it's a global and not on an object basis, it's causing the problem. I think the solution would be to associate a pointer from the perl side (ie, Duk*) into the actual duktape (ie, ctx*) and remove the global struct above.
Thoughts?
Regards,
The text was updated successfully, but these errors were encountered: