Project

Profile

Help

Bug #4639

closed

SaxonJS in Electron appears non-standard.

Added by Grant Vergottini over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Low
Category:
-
Sprint/Milestone:
-
Start date:
2020-07-10
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-
Actions #1

Updated by Michael Kay over 4 years ago

Could you expand on this please?

Actions #2

Updated by Grant Vergottini over 4 years ago

I don’t know where my description disappeared to.

I am finding the require(‘saxon-js’) does not work as expected in a node.js service within electron.

In a normal node.js environment, this works:

const SaxonJS = require(‘saxon-js’); // SaxonJS = an object with methods

However, in Electron, the exact same code results in SaxonJS being just the empty object {}.

In experimenting, I discovered that:

const foobar = require(‘saxon-js’); // SaxonJS is assigned properly somehow, foobar = undefined

Or even just:

require(‘saxon-js’); // SaxonJS is assigned properly somehow

would result in the SaxonJS object magically being defined. It appears that, at least in Electron’s way of scoping variables, the SaxonJS object is globally defined within the require() and that the assignment to an external constant of the same name mucks things up in a way that causes the resulting SaxonJS object to be an empty object

Actions #3

Updated by Debbie Lockett over 4 years ago

  • Project changed from Saxon to SaxonJS

Thanks for logging this issue. We have no experience of Electron, but will certainly need to investigate this.

Actions #4

Updated by Debbie Lockett over 4 years ago

As suggested, we are indeed declaring SaxonJS as a global variable internally, as well as adding it to module.exports; and I can believe that this is the cause of the problem.

I'm currently testing changes to remove the global variable, to check for regression. (Running our usual browser and Node.js test suite test drivers, and Mocha test suites).

I haven't actually tested anything in Electron though.

Actions #5

Updated by Debbie Lockett over 4 years ago

  • Status changed from New to In Progress

Changes committed to remove the SaxonJS global variable declaration in externs, and use the platform.expose method to expose the SaxonJS object as required (i.e. add to module.exports on Node.js, and add to window object as global variable in browser).

Hopefully this is a fix for the bugs #4639, #4669. Still need to do some more testing to confirm.

Actions #6

Updated by Debbie Lockett over 4 years ago

  • Assignee set to Debbie Lockett
Actions #7

Updated by Debbie Lockett over 4 years ago

Code changes reverted. The changes had caused our W3C test driver to break when running on Node.js, because it assumes that SaxonJS is a global. We need to rethink this.

Actions #8

Updated by Debbie Lockett almost 4 years ago

  • Applies to JS Branch 2 added
Actions #9

Updated by Norm Tovey-Walsh almost 4 years ago

  • Status changed from In Progress to Resolved

The SaxonJS internals have been adjusted so that they neither create nor rely on a global "SaxonJS" object. I was able to construct a small Electron application and demonstrate that SaxonJS could be loaded with require().

Actions #10

Updated by Norm Tovey-Walsh over 3 years ago

  • Status changed from Resolved to Closed

This issue has been resolved in the Saxon 2.2 maintenance release.

Actions #11

Updated by Debbie Lockett over 3 years ago

  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.2
  • Fix Committed on JS Branch 2 added

Please register to edit this issue

Also available in: Atom PDF Tracking page