laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.52k stars 697 forks source link

Requests in chrome fail with "Err_failed" but only when they are a XHR. #1098

Closed atymic closed 2 years ago

atymic commented 3 years ago

Clear description of your problem

Requests in chrome fail with "Err_failed" but only when they are a XHR. I've been scratching my head with this one for ages. For some reason, XHR requests to valet fail, but loading the page in a new tab works fine.

It's not a cors error, because the options request are marked as failed as well.

Wondering if anyone else is having an issue? Seems to only occur after updating chrome yesterday. Tried re-installing latest chrome, which did not resolve the issue.

Screen Shot 2021-10-03 at 17 18 01

Internal network debug log provides no info.

t=184205 [st= 0] +REQUEST_ALIVE  [dt=16]
                  --> priority = "MEDIUM"
                  --> traffic_annotation = 101845102
                  --> url = "https://smsapi.test/api/v1/templates"
t=184205 [st= 0]    NETWORK_DELEGATE_BEFORE_URL_REQUEST  [dt=0]
t=184205 [st= 0]   +URL_REQUEST_START_JOB  [dt=16]
                    --> initiator = "http://touchsms.local:8080"
                    --> load_flags = 64 (DO_NOT_SAVE_COOKIES)
                    --> method = "OPTIONS"
                    --> network_isolation_key = "http://domain.local"
                    --> privacy_mode = "enabled"
                    --> request_type = "other"
                    --> site_for_cookies = "SiteForCookies: {site=null; schemefully_same=false}"
                    --> url = "https://smsapi.test/api/v1/templates"
t=184205 [st= 0]      NETWORK_DELEGATE_BEFORE_START_TRANSACTION  [dt=2]
t=184207 [st= 2]      HTTP_CACHE_GET_BACKEND  [dt=0]
t=184207 [st= 2]     +HTTP_STREAM_REQUEST  [dt=14]
t=184207 [st= 2]        HTTP_STREAM_JOB_CONTROLLER_BOUND
                        --> source_dependency = 6851 (HTTP_STREAM_JOB_CONTROLLER)
t=184221 [st=16]        HTTP_STREAM_REQUEST_BOUND_TO_JOB
                        --> source_dependency = 6852 (HTTP_STREAM_JOB)
t=184221 [st=16]     -HTTP_STREAM_REQUEST
t=184221 [st=16]   -URL_REQUEST_START_JOB
                    --> net_error = -2 (ERR_FAILED)
t=184221 [st=16]    URL_REQUEST_DELEGATE_RESPONSE_STARTED  [dt=0]
t=184221 [st=16] -REQUEST_ALIVE
                  --> net_error = -2 (ERR_FAILED)

Expected behavior

Request to succeed

Steps to Reproduce

  1. Make an XHR from a different domain to a valet resource
  2. Not that it fails
  3. Load the page, and it succeeds

Possible solution

Firefox works fine šŸ™ƒ

Diagnosis

sw_vers
ProductName:   macOS
ProductVersion: 11.5.2
BuildVersion:   20G95
valet --version
Laravel Valet 2.16.0
cat ~/.config/valet/config.json
{
    "tld": "test",
    "paths": [
        "/Users/user/.config/valet/Sites",
        "/Users/user/code/laravel"
    ],
    "loopback": "127.0.0.1"
}
cat ~/.composer/composer.json
{
    "require": {
        "laravel/valet": "^2.11",
        "laravel/vapor-cli": "dev-fix/default-push",
        "laravel/installer": "^4.0",
        "beyondcode/expose": "2.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/atymic/vapor-cli"
        }
    ]
}
composer global diagnose
Changed current directory to /Users/user/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
require.beyondcode/expose : exact version constraints (2.0) should be avoided if the package follows semantic versioning
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: You are not running the latest stable version, run `composer self-update` to update (2.1.3 => 2.1.8)
Composer version: 2.1.3
PHP version: 7.4.22
PHP binary path: /usr/local/Cellar/php@7.4/7.4.22/bin/php
OpenSSL version: OpenSSL 1.1.1k  25 Mar 2021
cURL version: 7.78.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1k
zip: extension present, unzip present
composer global outdated
Changed current directory to /Users/user/.composer
Legend:
! patch or minor release available - update recommended
~ major release available - update possible
aws/aws-sdk-php            3.193.0                      ! 3.196.1 AWS SDK for PHP - Use Amazon Web Services in your PHP project
beyondcode/expose          2.0.0                        ! 2.0.2   Create public URLs for local sites through any firewall and VPN.
composer/ca-bundle         1.2.10                       ! 1.2.11  Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
guzzlehttp/psr7            1.8.2                        ~ 2.0.0   PSR-7 message implementation that also provides common utility methods
illuminate/collections     v8.60.0                      ! v8.62.0 The Illuminate Collections package.
illuminate/container       v8.60.0                      ! v8.62.0 The Illuminate Container package.
illuminate/contracts       v8.60.0                      ! v8.62.0 The Illuminate Contracts package.
illuminate/filesystem      v8.60.0                      ! v8.62.0 The Illuminate Filesystem package.
illuminate/macroable       v8.60.0                      ! v8.62.0 The Illuminate Macroable package.
illuminate/support         v8.60.0                      ! v8.62.0 The Illuminate Support package.
laravel/vapor-cli          dev-fix/default-push 0e72200 The Laravel Vapor CLI
league/flysystem           1.1.5                        ~ 2.3.0   Filesystem abstraction: Many filesystems, one API.
league/flysystem-aws-s3-v3 1.0.29                       ~ 2.1.0   Flysystem adapter for the AWS S3 SDK v3.x
league/mime-type-detection 1.7.0                        ! 1.8.0   Mime-type detection for Flysystem
padraic/phar-updater       v1.0.6                       = v1.0.6  A thing to make PHAR self-updating easy and secure.
Package padraic/phar-updater is abandoned, you should avoid using it. No replacement was suggested.
psr/container              1.1.1                        ~ 2.0.1   Common Container Interface (PHP FIG PSR-11)
ramsey/uuid                4.2.1                        ! 4.2.3   A PHP library for generating and working with universally unique identifiers (UUIDs).
symfony/translation        v5.3.7                       ! v5.3.9  Provides tools to internationalize your application
symfony/var-dumper         v5.3.7                       ! v5.3.8  Provides mechanisms for walking through any arbitrary PHP variable
vlucas/phpdotenv           v5.3.0                       ! v5.3.1  Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
ls -al /etc/sudoers.d/
total 16
drwxr-xr-x   4 root  wheel   128 13 Sep 13:10 .
drwxr-xr-x  87 root  wheel  2784 13 Sep 13:11 ..
-rw-r--r--   1 root  wheel    80  1 Apr  2021 brew
-rw-r--r--   1 root  wheel    83  1 Apr  2021 valet
brew config
HOMEBREW_VERSION: 3.2.14
ORIGIN: https://github.com/Homebrew/brew
HEAD: 4e6919b73444e9f9e02ad81d8afc4bbd97533567
Last commit: 4 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 944cb36e2a324ed2cb51d35f9628b64668777cee
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nano
HOMEBREW_MAKE_JOBS: 16
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 16-core 64-bit kabylake
Clang: 13.0.0 build 1300
Git: 2.32.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.5.2-x86_64
CLT: 12.5.1.0.1.1623191612
Xcode: 13.0
brew services list
256
Name          Status  User Plist
blackfire     stopped      
dnsmasq       stopped      
httpd         stopped      
memcached     stopped      
mysql         started user /Users/user/Library/LaunchAgents/homebrew.mxcl.mysql.plist
nginx         stopped      
php           stopped      
php@7.2       stopped      
php@7.3       stopped      
php@7.4       stopped      
postgresql    stopped      
postgresql@12 error   user /usr/local/opt/postgresql@12/homebrew.mxcl.postgresql@12.plist
redis         started user /Users/user/Library/LaunchAgents/homebrew.mxcl.redis.plist
unbound       stopped
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.85
mysql 8.0.25_1
nginx 1.19.5 1.19.4 1.19.3 1.19.8 1.21.1
openssl@1.1 1.1.1k
php 8.0.8_1 8.0.6_1
php@7.2 7.2.34_4
php@7.3 7.3.29_1
php@7.4 7.4.22 7.4.21_1
brew outdated
aom
asdf
automake
aws/tap/aws-sam-cli
awscli
bdw-gc
blackfireio/blackfire/blackfire
c-ares
cmake
composer
aws/tap/copilot-cli
coreutils
curl
dav1d
dnsmasq
exiftool
fio
fmt
folly
freetds
fribidi
gd
gdbm
gh
git
glib
gmp
go
gobject-introspection
graphviz
guile
harfbuzz
htop
httpd
shivammathur/extensions/igbinary@7.4
shivammathur/extensions/imap@7.3
jansson
jasper
k6
leptonica
libass
libidn
libpq
libssh2
libvpx
libzip
aws/tap/lightsailctl
m4
memcached
mysql
mysql-client
netpbm
nghttp2
nginx
openjdk
openldap
openssl@1.1
pango
php
php@7.3
php@7.4
postgresql
postgresql@12
python@3.8
python@3.9
readline
redis
sdl2
secrethub/tools/secrethub-cli
sqlmap
svn
unbound
watchman
webp
wget
xorgproto
yarn
zimg
font-jetbrains-mono
inkscape
mysqlworkbench
brew tap
adoptopenjdk/openjdk
aws/tap
blackfireio/blackfire
homebrew/cask
homebrew/cask-fonts
homebrew/core
homebrew/services
nicoverbruggen/cask
samuelmeuli/tap
secrethub/tools
shivammathur/extensions
shivammathur/php
timescale/tap
php -v
PHP 7.4.22 (cli) (built: Jul 29 2021 17:27:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.22, Copyright (c), by Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans
    with blackfire v1.56.0~mac-x64-non_zts74, https://blackfire.io, by Blackfire
which -a php
/usr/local/bin/php
/usr/bin/php
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/99-blackfire.ini,
/usr/local/etc/php/7.4/conf.d/error_log.ini,
/usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/igbinary.ini,
/usr/local/etc/php/7.4/conf.d/memcached.ini,
/usr/local/etc/php/7.4/conf.d/msgpack.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.21.1
curl --version
curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 7.78.0
Age => 9
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin20.4.0
SSL Version => (SecureTransport) OpenSSL/1.1.1k
ZLib Version => 1.2.11
libSSH Version => libssh2/1.9.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value
~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.40
ls -al ~/.ngrok2
total 8
drwx------    3 user  staff    96 22 Mar  2021 .
drwxr-xr-x+ 124 user  staff  3968  3 Oct 17:19 ..
-rw-------    1 user  staff    61 22 Mar  2021 ngrok.yml
brew info nginx
nginx: stable 1.21.3 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.19.3 (22 files, 2.2MB)
  Built from source
/usr/local/Cellar/nginx/1.19.4 (25 files, 2.2MB)
  Poured from bottle on 2020-11-02 at 14:09:44
/usr/local/Cellar/nginx/1.19.5 (25 files, 2.2MB)
  Poured from bottle on 2020-12-01 at 11:25:10
/usr/local/Cellar/nginx/1.19.8 (25 files, 2.2MB)
  Poured from bottle on 2021-03-30 at 16:41:02
/usr/local/Cellar/nginx/1.21.1 (25 files, 2.2MB) *
  Poured from bottle on 2021-07-19 at 10:57:33
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@1.1, pcre
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To start nginx:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/nginx/bin/nginx -g 'daemon off;'
==> Analytics
install: 47,001 (30 days), 120,977 (90 days), 518,469 (365 days)
install-on-request: 46,854 (30 days), 120,642 (90 days), 515,889 (365 days)
build-error: 0 (30 days)
brew info php
php: stable 8.0.11 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/8.0.6_1 (500 files, 77.8MB)
  Poured from bottle on 2021-05-14 at 14:55:06
/usr/local/Cellar/php/8.0.8_1 (500 files, 77.9MB)
  Poured from bottle on 2021-07-19 at 10:53:15
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, glib, gmp, icu4c, krb5, libffi, libpq, libsodium, libzip, oniguruma, openldap, openssl@1.1, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
    Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

    
        SetHandler application/x-httpd-php
    

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/8.0/

To start php:
  brew services start php
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/php/sbin/php-fpm --nodaemonize
==> Analytics
install: 47,956 (30 days), 150,947 (90 days), 623,181 (365 days)
install-on-request: 47,266 (30 days), 148,540 (90 days), 611,772 (365 days)
build-error: 0 (30 days)
brew info openssl
openssl@3: stable 3.0.0 (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@3.rb
License: Apache-2.0
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@3/certs

and run
  /usr/local/opt/openssl@3/bin/c_rehash

openssl@3 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

==> Analytics
install: 30,082 (30 days), 30,082 (90 days), 30,088 (365 days)
install-on-request: 24,289 (30 days), 24,289 (90 days), 24,295 (365 days)
build-error: 0 (30 days)
openssl version -a
LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx) 
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
openssl ciphers
ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:GOST2012256-GOST89-GOST89:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA256:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA
sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
which -a php-fpm
/usr/local/sbin/php-fpm
/usr/sbin/php-fpm
/usr/local/opt/php/sbin/php-fpm -v
PHP 8.0.8 (fpm-fcgi) (built: Jul 12 2021 11:13:48)
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies
    with blackfire v1.56.0~mac-x64-non_zts80, https://blackfire.io, by Blackfire
sudo /usr/local/opt/php/sbin/php-fpm -y /usr/local/etc/php/7.4/php-fpm.conf --test
[03-Oct-2021 17:20:24] NOTICE: configuration file /usr/local/etc/php/7.4/php-fpm.conf test is successful
ls -al ~/Library/LaunchAgents | grep homebrew
-rwxr-xr-x   1 user  staff   543  2 Sep  2020 homebrew.mxcl.mysql.plist
-rwxr-xr-x   1 user  staff   725  3 Feb  2021 homebrew.mxcl.postgresql@12.plist
-rwxr-xr-x   1 user  staff   823  1 Apr  2021 homebrew.mxcl.redis.plist
ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--   1 root  admin   657  3 Oct 17:06 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 root  admin   571  3 Oct 17:10 homebrew.mxcl.nginx.plist
-rw-r--r--   1 root  admin   577 30 Sep 09:11 homebrew.mxcl.php.plist
-rw-r--r--   1 root  admin   636  3 Oct 17:06 homebrew.mxcl.php@7.4.plist
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."

ls -aln /etc/resolv.conf
lrwxr-xr-x  1 0  0  22  1 Jan  2020 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
nameserver 10.13.37.1
ifconfig lo0
lo0: flags=8049 mtu 16384
    options=1203
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201
sh -c 'echo "------\n/usr/local/etc/nginx/valet/valet.conf\n---\n"; cat /usr/local/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
------
/usr/local/etc/nginx/valet/valet.conf
---

3:    #listen VALET_LOOPBACK:80; # valet loopback

------
sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
------
~/.config/valet/dnsmasq.d/tld-test.conf
---

address=/.test/127.0.0.1
listen-address=127.0.0.1

------
atymic commented 3 years ago

Interestingly, downgrading chrome to 93.0.4577.82 fixed the issue I tried upgrading again, and broken on fresh install šŸ˜•