-
Couldn't load subscription status.
- Fork 130
fix: add udp test to system test #2417
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
fix: add udp test to system test #2417
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Added UDP echo server functionality to the system test actor with client-side testing capabilities for network communication validation.
- Remove unnecessary
dgrampackage frompackage.jsonas it's a built-in Node.js module - Add timeout mechanism in
/examples/system-test-actor/tests/client.tsfor UDP response handling to prevent indefinite hangs - Convert UDP client operations in
/examples/system-test-actor/tests/client.tsto use proper async/await pattern - Consider adding cleanup handlers in
/examples/system-test-actor/src/container/main.tsfor UDP socket on server shutdown - Use existing actor object data instead of making additional API call for UDP port information
3 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
| "@types/deno": "^2.2.0", | ||
| "@types/node": "^22.13.9", | ||
| "@types/ws": "^8.18.0", | ||
| "dgram": "^1.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: dgram is a built-in Node.js module and should not be added as an npm dependency. Remove this line as it's not needed.
| "dgram": "^1.0.1", |
| }); | ||
|
|
||
|
|
||
| const port2 = Number.parseInt(portEnv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: No validation on port2 being a valid number - parseInt() could return NaN
| const port2 = Number.parseInt(portEnv); | |
| const port2 = Number.parseInt(portEnv); | |
| if (isNaN(port2)) { | |
| console.error('Invalid PORT_UDP value'); | |
| process.exit(1); | |
| } |
| let res = await client.actor.get(actor.id, { | ||
| project: RIVET_PROJECT, | ||
| environment: RIVET_ENVIRONMENT, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Unnecessary API call - the UDP port info is already available in the original actor object from line 34
| let res = await client.actor.get(actor.id, { | |
| project: RIVET_PROJECT, | |
| environment: RIVET_ENVIRONMENT, | |
| }); | |
| // Use UDP port info from the original actor object | |
| const udpPort = actor.network.ports.udp; |
| // Create a UDP socket | ||
| const udpClient = dgram.createSocket('udp4'); | ||
|
|
||
| // Send a message to the UDP echo server | ||
| const message = Buffer.from('Hello UDP server!'); | ||
| udpClient.send(message, udpPort.port, udpPort.hostname, (err) => { | ||
| if (err) { | ||
| console.error("Error sending UDP message:", err); | ||
| udpClient.close(); | ||
| } else { | ||
| console.log("UDP message sent"); | ||
| } | ||
| }); | ||
|
|
||
| // Listen for a response | ||
| udpClient.on('message', (msg, rinfo) => { | ||
| console.log(`UDP message received: ${msg.toString()}`); | ||
| console.log(`From: ${rinfo.address}:${rinfo.port}`); | ||
| udpClient.close(); | ||
| }); | ||
|
|
||
| udpClient.on('error', (err) => { | ||
| console.error("UDP client error:", err); | ||
| udpClient.close(); | ||
| }); | ||
|
|
||
| udpClient.on('close', () => { | ||
| console.log("UDP connection closed"); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: UDP operations are not properly awaited - wrap in Promise to ensure completion before test continues
42a5321 to
8b0fadf
Compare
9a55386 to
09dc9ec
Compare
Merge activity
|
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->

Changes