erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.15k stars 2.92k forks source link

question about DIST: SPAWN_REQUEST-SPAWN_REPLY. Always returns PID in the reply. #8603

Closed halturin closed 1 week ago

halturin commented 1 week ago

I'm playing with the "spawn request" feature (introduced in OTP 23) and didn't get the behavior.

On any SPAWN_REQUEST I receive SPAWN_REPLY with a pid. Even if I use random names for the "module" and/or "function" it returns a pid. I was expected to see an error on the failure of spawning. How can I ensure that the PID I'm receiving is a PID of the real process? not the fake one.

There are no details about that in the docs.

garazdawi commented 1 week ago

Why do you need to know that? The only way to know that the process successfully started is by it sending a message back to you or if you monitor/link to it.

halturin commented 1 week ago

I'm the author of Ergo Framework https://github.com/ergo-services/ergo. It implements Erlang network stack in golang https://github.com/ergo-services/proto (this implementation for the coming release of Ergo Framework 3.0).

jhogberg commented 1 week ago

Thanks for your report! This is the intended behavior. The process won't crash until it tries to run the bogus MFA that you have specified, which it cannot do until it has been successfully spawned. In interactive mode it will also attempt to load the module in question, which may or may not succeed, and we cannot hold off on SPAWN_REPLY for that.

As @garazdawi mentioned, if you want to know how things went after the process was spawned, either have it send a message or monitor/link it.

halturin commented 1 week ago

Thanks for the clarification