Closed owtotwo closed 2 years ago
A reproducible public repo: test_vercel_dev Steps:
I tried reproducing on my another win10-PC. Its environment is pure. I installed nodejs, python3 from their official website, then installed vercel by npm. Their verisons are as below.
PS C:\Users\at\Desktop> py --version
Python 3.8.5
PS C:\Users\at\Desktop> npm --version
6.14.8
PS C:\Users\at\Desktop> node --version
v14.9.0
PS C:\Users\at\Desktop> vercel --version
Vercel CLI 20.1.0
20.1.0
PS C:\Users\at\Desktop>
Logined by vercel cli, cloned the repo and ran command vercel dev
.
Then opened the link http://localhost:3000/, it's ok.
But if I opened http://localhost:3000/api/date, the logs said as below.
(* Different from the first Win10-PC, but the wrong file is the same:
C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py
.)
PS C:\Users\at\Desktop\test_vercel_dev> vercel dev
Vercel CLI 20.1.0 dev (beta) — https://vercel.com/feedback
> Ready! Available at http://localhost:3000
> Building @vercel/python@latest:api/date.py
Installing required dependencies...
> Built @vercel/python@latest:api/date.py [4s]
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py", line 147, in <module>
File "C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py", line 147, in <module>
lambda_runtime_main()
File "C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py", line 127, in lambda_runtime_main
lambda_runtime_main()
File "C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py", line 127, in lambda_runtime_main
fn = lambda_runtime_get_handler()
File "C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py", line 113, in lambda_runtime_get_handler
fn = lambda_runtime_get_handler()
File "C:\Users\at\AppData\Local\co.zeit.fun\Cache\runtimes\python\bootstrap.py", line 113, in lambda_runtime_get_handler
mod = importlib.import_module(module_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
mod = importlib.import_module(module_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "__import__(name)
C:\Users\at\AppData\Local\Temp\zeit-fun-8155162f673d2\now__handler__python.py File "", line C:\Users\at\AppData\Local\Temp\zeit-fun-8155162f673d2\now__handler__python.py200", line
200
async def receive(self):
async def receive(self):
^
SyntaxError : ^
iSyntaxErrornvalid syntax:
invalid syntax
TypeError: Object prototype may only be an Object or null: undefined
at Function.setPrototypeOf (<anonymous>)
at new LambdaError (C:\Users\at\AppData\Roaming\npm\node_modules\vercel\dist\index.js:7870:16)
at Lambda.<anonymous> (C:\Users\at\AppData\Roaming\npm\node_modules\vercel\dist\index.js:7990:27)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\at\AppData\Roaming\npm\node_modules\vercel\dist\index.js:7898:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
factoryDestroyError {
err: Error: Command failed: taskkill /pid 1992 /T /F
����: û���ҵ����� "1992"��
at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:486:12)
at maybeClose (internal/child_process.js:1047:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
killed: false,
code: 128,
signal: null,
cmd: 'taskkill /pid 1992 /T /F'
}
}
Update to Vercel CLI 20.1.4 dev (beta), do the same things like above, and it reported different errors like below.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
~\..\test_vercel_dev $ vercel dev
Vercel CLI 20.1.4 dev (beta) — https://vercel.com/feedback
> Ready! Available at http://localhost:3000
> Building @vercel/python@latest:api/date.py
Installing required dependencies...
> Built @vercel/python@latest:api/date.py [6s]
TypeError: Object prototype may only be an Object or null: undefined
at Function.setPrototypeOf (<anonymous>)
at new LambdaError (C:\Users\AT\AppData\Roaming\npm\node_modules\vercel\dist\index.js:7870:16)
at Lambda.<anonymous> (C:\Users\AT\AppData\Roaming\npm\node_modules\vercel\dist\index.js:7990:27)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\AT\AppData\Roaming\npm\node_modules\vercel\dist\index.js:7898:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Same problem here ! But works without dev!
I can confirm the behavior. Have similar errors <class 'OSError'>
using vercel dev
, including the latest greatest (at the moment of the comment) version: Vercel CLI 23.1.2
.
I've installed the Python 3.8.6 (the same as production runtime of Vercel), and got an error in bootstrap.py
file: <root>\co.zeit.fun\Cache\runtimes\python\bootstrap.py
.
Which produces a javascript error: TypeError: Cannot read property 'resolve' of null
inside of npm\node_modules\vercel\dist\index.js:11569:31
file.
UPD. As @owtotwo mentioned, it works on WSL. In my case it was Ubuntu 20.
Same problem here
PS C:> py -V Python 3.10.2 PS C:> pip -V pip 22.0.3 PS C:> vercel --version Vercel CLI 24.0.0 24.0.0 PS C:> node --version v14.17.2
Same problem here
Hi, guys, I finally figure out why it fails in windows: the stderr will emit data
event multiple times when spawning the python executable bin, for instance:
child.stderr.on('data', (d) => {
console.log('stderr data emitted:', d.toString());
});
stderr data emitted: Python was not found; run without arguments
stderr data emitted: to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Thus, if the python binary probing failed, the handle
function (as the callback of stderr) will be incorrectly triggered multiple times: https://github.com/vercel/fun/blob/af20f0cd2d56c6949257a925bb1113fa48a761b4/src/runtimes/python3/bootstrap.ts#L27
However, handler is only expected to be called once, otherwise, it will spawn multiple processes of bootstrap.py
then consequently call the /invocation/next
endpoint multiple times:
https://github.com/vercel/fun/blob/af20f0cd2d56c6949257a925bb1113fa48a761b4/src/runtimes/python/bootstrap.py#L56
Finally, the runtime-server
will receive multiple invokation/next
requests, and it will fail at this point:
https://github.com/vercel/fun/blob/af20f0cd2d56c6949257a925bb1113fa48a761b4/src/runtime-server.ts#L109-L110
the nextDeferred
will be immediately set to null
, so after the first call, all the subsequence calls will fail with such error:
TypeError: Cannot read property 'resolve' of null
I will send a PR soon to fix it.
There is something wrong with
vercel dev
command in my Windows 10.(* The content of date.py is same as this file as follows.)
I ran command
vercel dev
, then it saidurllib.error.HTTPError: HTTP Error 500: Internal Server Error
when it calledreq = urllib.request.urlopen(url, data)
in line 31 in bootstrap.py.After I add
print(url)
in bootstrap.py, line 31. The logs showed:In addition: I did the same thing in WSL(Ubuntu18.04) in this Windows PC, it works well.
So maybe it could not reproduce in other PC.