nodejs/node · error

CollationDataWriter::writeTailoring() failed: %s

Error message

CollationDataWriter::writeTailoring() failed: %s

What it means

After successfully allocating the collation output buffer, CollationDataWriter::writeTailoring() was called a second time (with the correct buffer size) and returned a UErrorCode failure. This means the tailoring data itself is internally inconsistent — the writer could not serialize it even with adequate buffer space. This is a data-level failure, not a resource failure.

Source

Thrown at deps/icu-small/source/tools/genrb/parse.cpp:1355

    int32_t indexes[icu::CollationDataReader::IX_TOTAL_SIZE + 1];
    int32_t totalSize = icu::CollationDataWriter::writeTailoring(
            *t, *t->settings, indexes, dest, capacity, intStatus);
    if(intStatus == U_BUFFER_OVERFLOW_ERROR) {
        intStatus = U_ZERO_ERROR;
        capacity = totalSize;
        dest = buffer.allocateInsteadAndCopy(capacity);
        if(dest == nullptr) {
            fprintf(stderr, "memory allocation (%ld bytes) for file contents failed\n",
                    static_cast<long>(capacity));
            *status = U_MEMORY_ALLOCATION_ERROR;
            res_close(result);
            return nullptr;
        }
        totalSize = icu::CollationDataWriter::writeTailoring(
                *t, *t->settings, indexes, dest, capacity, intStatus);
    }
    if(U_FAILURE(intStatus)) {
        fprintf(stderr, "CollationDataWriter::writeTailoring() failed: %s\n",
                u_errorName(intStatus));
        res_close(result);
        return nullptr;
    }
    if(isVerbose()) {
        printf("%s~%s collation tailoring part sizes:\n", state->filename, collationType);
        icu::CollationInfo::printSizes(totalSize, indexes);
        if(t->settings->hasReordering()) {
            printf("%s~%s collation reordering ranges:\n", state->filename, collationType);
            icu::CollationInfo::printReorderRanges(
                    *t->data, t->settings->reorderCodes, t->settings->reorderCodesLength);
        }
#if 0  // debugging output
    } else {
        printf("%s~%s collation tailoring part sizes:\n", state->filename, collationType);
        icu::CollationInfo::printSizes(totalSize, indexes);
#endif
    }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Read the u_errorName code in the message to identify the specific data error (e.g. U_ILLEGAL_ARGUMENT_ERROR, U_INVALID_FORMAT_ERROR)
  2. Validate the collation rules in the source .txt file — check reorder codes, rule syntax, and base collation references
  3. Compare the collation rules against the ICU CLDR source version that matches your ICU version
  4. If using custom (non-CLDR) rules, simplify them to isolate which rule triggers the failure
  5. Ensure the ICU data version matches the ICU library version (mismatches cause data format errors)
Defensive patterns

Strategy: validation

Validate before calling

# Validate collation rules before full genrb build
# Check for common issues in collation rule files
for f in data/*.txt; do
    # Check for valid reorder codes
    grep -n 'reorder' "$f" | grep -vP 'reorder\s*[:\s]*(Hani|Latn|Cyrl|Grek|Hangl|Kana|Ethi|Hebr|Arab|Thaa|Deva|Beng|Guru|Gujr|Taml|Telu|Knda|Mlym|Sinh|Thai|Laoo|Khmr|Myam|Tibt|Geor|Armn|Zyyy|Zinh|Zzzz)' && echo "Suspicious reorder code in $f"
done

Prevention

When it happens

Trigger: A collation tailoring with internally inconsistent data: invalid reordering codes, contradictory rule settings, unset required fields in the CollationTailoring struct, or a tailoring whose settings do not match its base data. The first writeTailoring call computed the size, but the second call found a data problem.

Common situations: Custom collation rules with invalid script reordering codes; a locale's collation data that references a non-existent base collation; ICU version mismatch where the CollationDataWriter API changed; corrupted or partially-generated collation rules from a failed prior step.

Related errors


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