nodejs/node · error
U_FAILURE
U_FAILURE
Error message
icupkg: udata_openSwapper(\"%s\") failed - %s\n
What it means
Thrown by Package::readPackage() when udata_openSwapper() returns a failure UErrorCode. The swapper is created to handle byte-order and charset conversion between the input data's native format (determined by makeTypeProps from the type letter) and the host's format. If the swapper cannot be initialized, the input format combination is unsupported.
Source
Thrown at deps/icu-small/source/tools/toolutil/package.cpp:471
char type;
const UDataOffsetTOCEntry *inEntries;
extractPackageName(filename, inPkgName, static_cast<int32_t>(sizeof(inPkgName)));
/* read the file */
inData=readFile(nullptr, filename, inLength, type);
length=inLength;
/*
* swap the header - even if the swapping itself is a no-op
* because it tells us the header length
*/
errorCode=U_ZERO_ERROR;
makeTypeProps(type, inCharset, inIsBigEndian);
ds=udata_openSwapper(inIsBigEndian, inCharset, U_IS_BIG_ENDIAN, U_CHARSET_FAMILY, &errorCode);
if(U_FAILURE(errorCode)) {
fprintf(stderr, "icupkg: udata_openSwapper(\"%s\") failed - %s\n",
filename, u_errorName(errorCode));
exit(errorCode);
}
ds->printError=printPackageError;
ds->printErrorContext=stderr;
headerLength=sizeof(header);
if(length<headerLength) {
headerLength=length;
}
headerLength=udata_swapDataHeader(ds, inData, headerLength, header, &errorCode);
if(U_FAILURE(errorCode)) {
exit(errorCode);
}
/* check data format and format version */
pInfo = reinterpret_cast<const UDataInfo*>(reinterpret_cast<const char*>(inData) + 4);View on GitHub (pinned to 1b2de5e052)
Solutions
- Check the error message suffix (u_errorName output) for the specific UErrorCode.
- Ensure the ICU build includes the necessary conversion tables for the source charset.
- Use an icupkg version matching the ICU version that produced the data file.
- If EBCDIC data is involved, build ICU with EBCDIC conversion support enabled.
Defensive patterns
Strategy: validation
Validate before calling
// Verify the .dat file's type letter is supported before processing
#include <cstring>
bool isSupportedType(char typeLetter) {
// Supported types: 'l' (little-endian ASCII), 'b' (big-endian ASCII),
// 'e' (EBCDIC, requires legacy conversion support)
return typeLetter == 'l' || typeLetter == 'b' || typeLetter == 'e';
} Prevention
- Ensure the ICU build has conversion support for the source data's charset.
- Use icupkg from the same ICU version that produced the data.
- Avoid EBCDIC-sourced data unless the build explicitly supports it.
When it happens
Trigger: Calling readPackage() on a .dat file where makeTypeProps(type, ...) produces a charset/endian combination that udata_openSwapper() cannot handle. The type is determined by getTypeEnumForInputData() during the initial readFile() pass, so this implies the file passed the initial format check but the swapper rejects the specific source platform parameters.
Common situations: A .dat file from an exotic platform (e.g. EBCDIC) that the host ICU build does not have conversion tables for; ICU version mismatch where the swapper API behavior changed; corrupt header values that produce invalid charset/endian flags.
Related errors
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/6588910eb93b5887.
Report an issue: GitHub.