Project

Profile

Help

Bug #4877

closed

AssertionError: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Array

Added by Michael Kay almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2021-01-14
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:
-

Description

We're getting this message from a number of the Node.js API tests, specifically

async-trans-015, -016, -020, -021, -022, -025, -026; sync-trans-015, -016, -020, -021

The stack trace shows

Received an instance of Array
   at Object.writeFileSync (fs.js:1409:5)
   at Object.writeFileSync (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:19959:11)
   at Object.save (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:26532:21)
   at $$onCompletion$$$ (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:13950:25)

and it's caused because we pass an array containing an XdmString to the "data" argument of fs.writeFileSync, rather than passing the underlying string.

There's a suggestion at

https://stackoverflow.com/questions/65137938/typeerror-err-invalid-arg-type-the-data-argument-must-be-of-type-string-or

that this might reflect a change in a recent version of the fs library (the spec suggests that any Object with a toString() method is accepted).

We're calling fs.writeFileSync() from a save() function; the user can supply a save() function, but if they don't, we supply our own. The documentation says that the format of the value passed to the save() function depends on the value of resultForm. In these tests there is no user-supplied resultForm option, so it ought to default to a Javascript string; this doesn't appear to be the case. But we also need to consider what happens if there is a user-supplied resultForm, in which case the system-supplied save() method might have to cope with different possibilities.

Please register to edit this issue

Also available in: Atom PDF Tracking page