nodejs/node · critical

icupkg: udata_openSwapper("%s") failed - %s

Error message

icupkg: udata_openSwapper("%s") failed - %s

What it means

Fatal error (calls exit) thrown when udata_openSwapper fails to create a data swapper for endian/charset conversion of a CNV-type item. The swapper is needed to normalize the converter data from the source platform's endianness/charset to the target platform's. The printed error includes the item name and the u_errorName() of the failure code.

Source

Thrown at deps/icu-small/source/tools/toolutil/pkgitems.cpp:619

            {
                /*
                 * Swap the resource bundle (if necessary) so that we can use
                 * the normal runtime uresdata.c code to read it.
                 * We do not want to duplicate that code, especially not together with on-the-fly swapping.
                 */
                NativeItem nrb(pItem, ures_swap);
                ures_enumDependencies(pItem->name, nrb.getDataInfo(), nrb.getBytes(), nrb.getLength(), check, context, this, &errorCode);
                break;
            }
        case FMT_CNV:
            {
                // TODO: share/cache swappers
                UDataSwapper *ds=udata_openSwapper(
                                    static_cast<UBool>(pInfo->isBigEndian), pInfo->charsetFamily,
                                    U_IS_BIG_ENDIAN, U_CHARSET_FAMILY,
                                    &errorCode);
                if(U_FAILURE(errorCode)) {
                    fprintf(stderr, "icupkg: udata_openSwapper(\"%s\") failed - %s\n",
                            pItem->name, u_errorName(errorCode));
                    exit(errorCode);
                }

                ds->printError=printError;
                ds->printErrorContext=stderr;

                const uint8_t *inBytes=pItem->data+itemHeaderLength;
                int32_t length=pItem->length-itemHeaderLength;

                ucnv_enumDependencies(ds, pItem->name, pInfo, inBytes, length, check, context, &errorCode);
                udata_closeSwapper(ds);
                break;
            }
        default:
            break;
        }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Rebuild the .cnv file from its .ucm source with makeconv to eliminate data corruption.
  2. Verify the ICU library and icupkg tool are from the same build/version to ensure API compatibility.
  3. Check available memory and system resources if udata_openSwapper fails with a memory-related error code.
Defensive patterns

Strategy: try-catch

Try / catch

// icupkg calls exit(); capture exit code and stderr
result = subprocess.run(['icupkg', 'data.dat'], capture_output=True)
if result.returncode != 0:
    stderr = result.stderr.decode()
    if 'udata_openSwapper' in stderr:
        print(f'Data swapper creation failed: {stderr}')

Prevention

When it happens

Trigger: In Package::enumDependencies for FMT_CNV items, udata_openSwapper is called with the source pInfo->isBigEndian/charsetFamily and the target U_IS_BIG_ENDIAN/U_CHARSET_FAMILY. If it returns U_FAILURE, fprintf at pkgitems.cpp:619 fires and exit(errorCode) is called.

Common situations: Corrupted or truncated CNV data that confuses the swapper; invalid pInfo header with impossible endianness/charset values; memory exhaustion during swapper creation; ICU library build inconsistency between the tool and the runtime data swapper API.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/2bef9d0289da98bd. Report an issue: GitHub.