Repository navigation
Fix quoting, encoding and error handling; add tests and CI - #56
Open
harendra-kumar wants to merge 32 commits into
Open
harendra-kumar wants to merge 32 commits into
harendra-kumar wants to merge 32 commits into
Conversation
Pin streamly-core-0.3.3 and streamly-0.11.1 (Hackage revision 3, which allows streamly-core < 0.3.4).
Port the example to run/runAt and the RunningConfig setters, use the generated RpcMap in the server, and update the generator config and READMEs to the current config format.
The flag adds +RTS -M2G -RTS to the GHC options. cabal.project enables it so that a local build does not exhaust the machine memory.
The test executable is also the RPC server for the endpoints in test/TestFunctions.hs. Fake ssh, scp, sudo and su first in PATH run the remote and privileged commands locally. test/Harness.hs provides assertions and QuickCheck properties. The heap is limited to 1G.
The input and output were decoded to a String and packed one Char per byte, so any non-ASCII character in an argument or result made the call fail. The server and the client now pass byte arrays to aeson and decode UTF-8 only for logging.
In a non-UTF-8 locale, e.g. LC_ALL=C in a non-interactive ssh session, printing a non-ASCII input, result or version raised an exception. invokeFunction and mainWith now set the stdout encoding to UTF-8, which the client expects.
Most errors were raised with error, so a caller could not match on the kind of error. Export RpcException from Simple.RPC.Common with a constructor for each error. Decode an invalid output line in IO before runAt returns.
Arguments were decoded lazily, so a bad argument failed only after the function's earlier effects, an unforced one was never checked, and extra arguments were ignored. The wrapper now checks the argument count and decodes every argument first, raising InvalidInput. Use newName for the generated local names, so that exporting a function named val compiles.
runAt returned a thunk, so a decoding error was raised where the caller forced the result, outside any handler around runAt. The result is now decoded in IO and an invalid one raises InvalidOutput.
The command was quoted with show, which does not quote for a shell, so paths with spaces or shell characters broke. Run the command as an argument list, and quote the commands given to su -c and ssh with single quotes.
runAt ignored rcImageFlags. It now passes the flags, split at white space, before the endpoint name.
installOnRemote ran chmod a+rw on the target directory and left it so. It also overwrote a running executable in place and quoted paths with show. It now copies to a mktemp file, installs it with sudo install -m 755, and quotes the remote commands for the shell.
Time toBinStream on large JSON values, and runAt with a large argument and a large result. The heap is limited to 1G.
toBinStream used BSL.index, which walks the chunk list from the start for every byte. It now unfolds the bytes of each chunk, and is inlined to fuse with the consumer. toChunkStream copies whole chunks.
streamly-process 0.4.1 keeps writing the input after the server exits, so an unknown endpoint with a large input gave a broken pipe error instead of the server error. invokeFunction now reads the input first. Add expected failure support to the test harness.
Call an endpoint evaluator from createRpcMap in process, and check that runAt logs an invalid UTF-8 output line and still decodes the result.
Correct the setRemote, setUser, defaultConfig and RpcSymbol docs, and document the version check, the output protocol, the steps of runAt and the requirements of rpcExport. Add module headers.
Wrap lines to 79 columns. Disable the missing role annotation warning of GHC 9.8, the inferred roles are intended.
Move the IR conversion section after IntermediateRep. The code is unchanged.
Windows cannot run the /bin/sh scripts. Each fake is now a copy of the test executable with a config file. Remove the unix dependency and skip the installOnRemote tests on Windows.
Based on the streamly CI using packcheck. Add cabal.project.ci with streamly-coreutils from git and cabal.project.Werror. The docspec job exposes the other-modules because cabal-docspec checks only exposed modules.
GHC translates \n to \r\n on the standard handles on Windows. Disable newline translation on stdout.
Document that setRemote needs a POSIX remote shell, that local sudo and su do not work on Windows, and that installOnRemote needs a compatible remote host. Add a Dependencies paragraph to runAt, installOnRemote, setRemote, setUser and useSudo.
Use the public modules for the functions they export. Only compactEndByLn_, fromPtrN, unsafePinnedAsPtr and ordNub are still imported from internal modules.
Replace the pointer-based copies in Types.hs with toArray and fromArray from streamly-bytestring. toArray does not copy the ByteString, and the internal fromPtrN and unsafePinnedAsPtr imports are no longer needed. Pin streamly-bytestring 0.2.3 revision 3, which allows streamly-core 0.3.3.
Decode the UTF-8 JSON bytes from toBinStream with Unicode.decodeUtf8, which also replaces invalid bytes with U+FFFD. Drop the text dependency of the library.
Convert the lazy JSON encoding to a byte or chunk stream with Streamly.External.ByteString.Lazy, and fold the input bytes of fromBinStream into a strict ByteString with StreamlyBS.write instead of building a list and packing it.
irArgs checks the length of the aeson array with Foldable length, which takes constant time, and returns the arguments as a list. createArr builds the array with toJSON. Neither needs to name the Vector type.
The endpoint table is looked up once per server process, so a Map from containers, which ships with GHC, does as well as a HashMap. Drop the unordered-containers dependency. RpcMap is exported, so record the type change in the changelog.
Take the directory of the remote path with Streamly.FileSystem.Path and drop the filepath dependency of the library. An empty path or one with a NUL character now raises InvalidPath before connecting.
Accept both the show and the displayException forms of an exception on the server stderr; GHC before 9.10 prints show. Expect CRLF on the endpoint stderr on Windows. Replace the deprecated withMaxSuccess by a propertyN harness function that sets maxSuccess.
adithyaov
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes bugs found while adding a test suite, and adds CI on Linux, macOS, Windows and FreeBSD.
See rpc/CHANGELOG.md for details.