Comments (9)
CC: @kevmoo.
from functions-framework-dart.
Do you already have a server running on your machine @ 8080?
Guessing that's it!
from functions-framework-dart.
I don't believe that's the cause of the initial failure. If I run the tests a second time, though, I do get that error:
00:01 +0 -1: test/function_test.dart: defaults [E]
Expected: should eventually emit an event that 'Listening on :8080'
Actual: <Instance of 'StreamQueue<String>'>
Which: emitted x Stream closed.
which never did emit an event that 'Listening on :8080'
package:test_api expectLater
test/function_test.dart 13:11 main.<fn>
===== asynchronous gap ===========================
dart:async _asyncThenWrapperHelper
test/function_test.dart main.<fn>
Process `dart bin/server.dart` exited with exitCode 255. Output:
[e] Unhandled exception:
[e] SocketException: Failed to create server socket (OS Error: Address already in use, errno = 48), address = 0.0.0.0, port = 8080
[e] #0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:962:7)
[e] <asynchronous suspension>
[e] #1 serve (package:shelf/shelf_io.dart:50:16)
[e] <asynchronous suspension>
[e] #2 run (package:functions_framework/src/run.dart:32:18)
[e] <asynchronous suspension>
[e] #3 _serve (package:functions_framework/serve.dart:127:3)
[e] <asynchronous suspension>
[e] #4 serve (package:functions_framework/serve.dart:53:5)
[e] <asynchronous suspension>
[e] #5 main (file:///Users/redbrogdon/source/hellow/bin/server.dart:20:3)
[e] <asynchronous suspension>
00:01 +0 -1: Some tests failed.
I believe the dart bin/server.dart
process initiated in the first run is hanging out in memory -- If I kill it manually, I can get back to the first error.
from functions-framework-dart.
That's 🍌 🍌 . Hrm...
from functions-framework-dart.
Glad you're trying this out!
from functions-framework-dart.
So? I've just created a project with the helloworld
template and I confirm that dart test
is failing out-of-the-box. That sounds very worrying; does it mean that there's a problem with the test, or maybe the function doesn't work at all?
from functions-framework-dart.
Do you already have a server running on your machine @ 8080?
Guessing that's it!
I cannot see in this section of the quickstart that it's required to manually start the server before running dart test
. Is it required?
from functions-framework-dart.
My output of running dart test
:
backend ✔ 33m ⍉
▶ dart test
00:01 +0 -1: test/function_test.dart: defaults [E]
Expected: <0>
Actual: <-15>
Process `dart bin/server.dart` had an unexpected exit code.
package:test_api expect
package:test_process/test_process.dart 228:5 TestProcess.shouldExit
===== asynchronous gap ===========================
test/function_test.dart 28:5 main.<fn>
Process `dart bin/server.dart` exited with exitCode -15. Output:
Listening on :8080
2021-12-23T11:49:26.447544 0:00:00.005582 GET [200] /
00:01 +0 -1: Some tests failed.
Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.
backend ✔ 33m ⍉
▶ lsof -i tcp:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dart 85133 jakub 12u IPv4 0x6f20cda13ac1c289 0t0 TCP *:http-alt (LISTEN)
So it seems that the function_test.dart
correctly starts the server process, it starts listening on the correct port, but for some reason the line...
proc.signal(ProcessSignal.sigterm);
...doesn't work as expected and doesn't stop the process. What bothers me is the -15 exit code. I'm not a great expert on *nix systems, but where could this exit code come from, if lsof
proves that the launched process never exited?
I've just checked, and the -15 exit code correspond to SIGTERM, which has signal id = 15.
From Process.exitCode
docs:
If the process was terminated due to a signal the exit code will be a negative value in the range
[-255..-1]
, where the absolute value of the exit code is the signal number.
It seems that it's expected that the exit code will be -15 if we send the sigterm to the process.
So the only mistery is why the server process, from one perspective, seems to exit with the (proper) -15 exit code, but on the other hand seems to be still alive and blocking the port.
from functions-framework-dart.
Would be awesome if we got this solved, what I could do to help was trying every single ProccessSignal const and did it. All of the maintain that process active and I had to do a lsof -i tcp:8080
then kill PID
, so here is a list of each signal sent and code return at macOS Monterey (12.1) M1 2020 on a direct git clone https://github.com/GoogleCloudPlatform/functions-framework-dart.git
then dart test test/function_test.dart
:
proc.signal(ProcessSignal.sigterm);
RESULT: -15
proc.signal(ProcessSignal.sighup);
-1
proc.signal(ProcessSignal.sigint);
-9
proc.signal(ProcessSignal.sigquit);
-9
proc.signal(ProcessSignal.sigill);
-4
proc.signal(ProcessSignal.sigtrap);
-5
proc.signal(ProcessSignal.sigabrt);
-6
proc.signal(ProcessSignal.sigbus);
-10
proc.signal(ProcessSignal.sigfpe);
-8
proc.signal(ProcessSignal.sigkill);
-9
proc.signal(ProcessSignal.sigusr1);
-30
proc.signal(ProcessSignal.sigsegv);
-11
proc.signal(ProcessSignal.sigusr2);
-31
proc.signal(ProcessSignal.sigpipe);
-9
proc.signal(ProcessSignal.sigalrm);
-14
proc.signal(ProcessSignal.sigterm);
-15
proc.signal(ProcessSignal.sigchld);
-9
proc.signal(ProcessSignal.sigcont);
-9
proc.signal(ProcessSignal.sigstop);
-9
proc.signal(ProcessSignal.sigtstp);
-9
proc.signal(ProcessSignal.sigttin);
-9
proc.signal(ProcessSignal.sigttou);
-9
proc.signal(ProcessSignal.sigurg);
-9
proc.signal(ProcessSignal.sigxcpu);
-24
proc.signal(ProcessSignal.sigxfsz);
-25
proc.signal(ProcessSignal.sigvtalrm);
-26
proc.signal(ProcessSignal.sigprof);
-27
proc.signal(ProcessSignal.sigwinch);
-9
proc.signal(ProcessSignal.sigpoll);
-9
proc.signal(ProcessSignal.sigsys);
-12
I think this might be related to package test_process
about file test_process.dart#L205 which says that TestProcess.Signal is not supported in Windows, this might be not supported by macOS also.
EDIT:
Just found that before sending sigterm
I've put a print(proc.pid);
which shows PID of dart bin/server.dart, but it's different from after error what we got at lsof -i tcp:8080
that means server.dart is creating a secondary process to listen but it is not dealing with that process when sending signal to end.
from functions-framework-dart.
Related Issues (20)
- Docker build failing HOT 8
- Error Reporting in Cloud Run HOT 4
- sample project created via dartfn should use official docker images HOT 3
- Docker files created by dartfn doesn't copy runtime files, causing launch to fail HOT 3
- dartfn: need to have a dependency to pkg:lints!
- dartfn: gitignore files should link to https://dart.dev/guides/libraries/private-files
- Cloud Run + Cloud SQL hanging issue HOT 25
- Pricing and/or other considerations regarding using Cloud Run for simulating Cloud Functions?
- Multiple functions in the same package HOT 3
- Docker images failing when deployed to cloud run when using apple silicon HOT 1
- Private SSH packages HOT 1
- Generated project (from dartfn) logs CloudEvent awkwardly HOT 3
- Allow Configuring "X-Powered-By" of underlying shelf server HOT 1
- Support for Protobufs in CloudEvents HOT 6
- Provide access to an instance's region from metadata HOT 1
- gcp: logging does not support jsonPayload HOT 1
- DRY up finishServerTest code and similar HOT 2
- Multiple funcitons in one project HOT 3
- BuildRunner seems to break the code HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functions-framework-dart.