Skip to content

Patch-package does not consistently run in Google Cloud Functions #160

Open
@ccw-morris

Description

@ccw-morris

This is an advisory note, to assist others with the same issue, rather than a request to change anything.

Google Cloud Functions is capable of running patch-package as a postinstall script as part of deployment of the function. But, it doesn't do it every time.

It appears that Cloud Functions cache the node_modules directory against a hash of the package.json file. So, if the patches are updated without changing package.json then the new patches will not be applied. Similarly, if the package.json is reverted to an earlier version that coexisted with a different set of patches then the function will use those earlier patches rather than the patches that currently exist in the cloud function bundle.

The solution is to always make a change to package.json whenever the patches directory is changed. To test this in my project, I changed one of the author tags and the current patches were applied correctly.

The observation about a cache is a guess based on generating different functions and observing the effects. Unfortunately, Google does not expose the deployment logs or code to enable verification.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions