Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support includeFiles and excludeFiles glob patterns, which Vercel requires #104

Closed
unitof opened this issue Aug 7, 2020 · 4 comments

Comments

@unitof
Copy link

unitof commented Aug 7, 2020

Bug report

Description

Vercel requires a function's includeFiles and excludeFiles to be a single glob string.

vercel-php expects an array, or a string. But it trips on many glob matching patterns.

There are two abutting issues:

  1. A now.jsonvercel.json file with an array in includeFiles or excludeFiles fails validation and refuses to deploy, even though that's what's recommended in vercel-php's documentation.
Error! Invalid now.json - `functions['api/index.php'].excludeFiles` Invalid request: `functions['api/index.php'].excludeFiles` should be string..
  1. vercel-php seems to trip on many non-trivial glob patterns (basically anything that's beyond a string ending in * or **). It will deploy, but with the following behavior:

On the first GET request, the request times out with a Vercel 502 NO_RESPONSE_FROM_FUNCTION error.
image

Vercel logs show the following:

🐘 Spawning: PHP Built-In Server at /var/task/user (document root) and /var/task/user/api/index.php (router)
2020-08-07T15:41:38.840Z	d9691f0f-b896-4a65-8b9e-2182919131a0	ERROR	🐘STDERR: Directory /var/task/user does not exist.
🐘 PHP Built-In Server process closed code 1 and signal null
2020-08-07T15:41:43.570Z	d9691f0f-b896-4a65-8b9e-2182919131a0	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"connect ECONNREFUSED 127.0.0.1:8000","code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8000,"stack":["Error: connect ECONNREFUSED 127.0.0.1:8000","    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)"]}

On all subsequent requests, PHP returns PHP Built-In Server HTTP error: Error: connect ECONNREFUSED 127.0.0.1:8000.

image

Vercel logs show:

🐘 Accessing juicyfx-php-test-nl5ugs3i9.vercel.app/api/index.php
🐘 Querying /api/index.php
2020-08-07T15:43:47.070Z	bf4f302d-3817-4f32-b291-e81deaf3274f	ERROR	🐘 PHP Built-In Server HTTP errored Error: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000
}

My temporary workaround is to use a single string with a simple glob pattern that vercel-php does seem to do okay with; in my case: excludeFiles: projects/**.

Glob patterns I've encountered this issue with:
!(file)
(fileA|fileB) (doesn't error, but appears to get parsed as a single exact filename, rather than a glob pattern)
**/*

@f3l1x
Copy link
Collaborator

f3l1x commented Aug 11, 2020

Hi, thanks for great report.

I have tested current version (0.3.1) and it works.

  • includeFiles is not supported, only excludeFiles
  • you can use string in excludedFiles (fixed in readme, thx)
  • you can combine .vercelignore with excludedFiles easily (take a look at example)

Take a look at my examples (https://github.com/juicyfx/vercel-php/tree/master/test/examples/18-exclude-files)

@unitof
Copy link
Author

unitof commented Aug 11, 2020

Aha! That likely explains my issues: I was using a excludeFiles: "**/*" and assuming includeFiles would then act as an allowlist, but in reality I was just excluding everything, probably the underlying cause of the PHP errors.

Will see if I can construct an excludeFiles glob that does what I need! (Basically, to exclude everything except one common api/functions.php file from each function's builder.)

@f3l1x
Copy link
Collaborator

f3l1x commented Aug 11, 2020

Yep, that's catchy. :-)

Vercel is using glob and it's using minimatch. You can test it here https://globster.xyz/.

@f3l1x
Copy link
Collaborator

f3l1x commented Sep 20, 2020

I am closing it now, feel free open it again.

@f3l1x f3l1x closed this as completed Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants