Skip to content

Can't cache python requirements due to updated last modification time #721

Closed
@dongho-jung

Description

@dongho-jung

as the title suggests, python requirements aren't being cached due to updated last modification time.

serverless-python-requirements can cache python requirements with lambda layer.
but in some cases, it can't.

I've investigated this issue for several days:

  • serverless says the hash of new pythonRequirements.zip is different with the hash of one in S3, so it should be uploaded again
  • however, when I compare all the files in local pythonRequirements.zip and S3 pythonRequirements.zip, their contents are all the same
  • finally found that, the last modification time of files is different..

this issue is mentioned before though, the problem is still exist.

In code, I think below snippet should fix this issue, but it couldn't its job.

// necessary to get the same hash when zipping the same content
date: new Date(0),

and I also found that it seems below snippet broke caching

// We'll "touch" the folder, as to bring it to the start of the FIFO cache
fse.utimesSync(workingReqsFolder, new Date(), new Date());

I don't know what the FIFO cache is in this context... but after I comment these lines out, the cache works like a charm.

please any comment on this. thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions