Skip to content

Conversation

@MasterPtato
Copy link
Contributor

Changes

Copy link
Contributor Author

MasterPtato commented Apr 30, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@MasterPtato MasterPtato mentioned this pull request Apr 30, 2025
Copy link

@greptile-apps greptile-apps bot left a 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 dgram package from package.json as it's a built-in Node.js module
  • Add timeout mechanism in /examples/system-test-actor/tests/client.ts for UDP response handling to prevent indefinite hangs
  • Convert UDP client operations in /examples/system-test-actor/tests/client.ts to use proper async/await pattern
  • Consider adding cleanup handlers in /examples/system-test-actor/src/container/main.ts for 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",
Copy link

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.

Suggested change
"dgram": "^1.0.1",

});


const port2 = Number.parseInt(portEnv);
Copy link

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

Suggested change
const port2 = Number.parseInt(portEnv);
const port2 = Number.parseInt(portEnv);
if (isNaN(port2)) {
console.error('Invalid PORT_UDP value');
process.exit(1);
}

Comment on lines +157 to +160
let res = await client.actor.get(actor.id, {
project: RIVET_PROJECT,
environment: RIVET_ENVIRONMENT,
});
Copy link

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

Suggested change
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;

Comment on lines +167 to +195
// 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");
});
Copy link

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

@cloudflare-workers-and-pages
Copy link

Deploying rivet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 42a5321
Status:🚫  Build failed.

View logs

@graphite-app
Copy link
Contributor

graphite-app bot commented May 2, 2025

Merge activity

  • May 1, 9:57 PM EDT: MasterPtato added this pull request to the Graphite merge queue.
  • May 1, 9:58 PM EDT: CI is running for this pull request on a draft pull request (#2422) due to your merge queue CI optimization settings.
  • May 1, 9:59 PM EDT: Merged by the Graphite merge queue via draft PR: #2422.

graphite-app bot pushed a commit that referenced this pull request May 2, 2025
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
@graphite-app graphite-app bot closed this May 2, 2025
@graphite-app graphite-app bot deleted the 04-30-fix_add_udp_test_to_system_test branch May 2, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants