Skip to content

[Bug] Invalid timestamp in generated archive #1882

Description

@nicolo-ribaudo
  • I'd be willing to implement a fix

Describe the bug

I'm using yarn npm publish to publish https://github.com/nicolo-ribaudo/babel-preset-current-node-syntax, and I got bug reports about invalid file timestamps on the npm registry: nicolo-ribaudo/babel-preset-current-node-syntax#6.

For some reason, they are all set to 1970-01-04+16:38:52.0000000000, which is invalid in zip archives.

I could also reproduce this using just yarn pack.

To Reproduce

Reproduction

Playground

const fs = require("fs").promises;
const cp = require("child_process");

await fs.writeFile("package.json", JSON.stringify({
name: "test",
version: "0.0.0"
}));
await fs.writeFile("./test-file", "test-file");
await yarn();

const { mtime: before } = await fs.stat("./test-file");
expect(before.toString()).toContain("2020");

await yarn(`pack`);

const stdout = cp.execSync(`tar -t -v --full-time -f package.tgz`);

expect(stdout.toString()).toContain("2020");

Output:

Error: �[2mexpect(�[22m�[31mreceived�[39m�[2m).�[22mtoContain�[2m(�[22m�[32mexpected�[39m�[2m) // indexOf�[22m

Expected substring: �[32m"2020"�[39m
Received string:    �[31m"-rw-r--r-- 0/0              42 1970-01-04 15:38:52 package/package.json�[39m
�[31m-rw-r--r-- 0/0               9 1970-01-04 15:38:52 package/test-file�[39m
�[31m"�[39m
at module.exports (evalmachine.<anonymous>:19:27)
at process._tickCallback (internal/process/next_tick.js:68:7)

Screenshots

If applicable, add screenshots to help explain your problem.

Environment if relevant (please complete the following information):

  • OS: Linux
  • Node version 14.10.1
  • Yarn version 2.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    broken-reproThe reproduction in this issue is brokenbugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions