Skip to content

Commit 4318ef7

Browse files
committed
fixes #9
1 parent 8663c1c commit 4318ef7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/mongo.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,8 @@ defmodule Mongo do
573573
end
574574
end
575575

576-
defp check_for_error(%{"ok" => ok} = response) when ok == 1 do
577-
{:ok, response}
578-
end
579-
defp check_for_error(%{"code" => code, "errmsg" => msg}) do
580-
{:error, Mongo.Error.exception(message: msg, code: code)}
581-
end
576+
defp check_for_error(%{"ok" => ok} = response) when ok == 1, do: {:ok, response}
577+
defp check_for_error(%{"code" => code, "errmsg" => msg} = err), do: {:error, Mongo.Error.exception(message: msg, code: code)}
582578

583579
@doc """
584580
Returns the current wire version.

lib/mongo/cursor.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ defmodule Mongo.Cursor do
155155
maxTimeMS: opts[:max_time]
156156
] |> filter_nils()
157157

158+
kill_cursors(conn, coll, [cursor_id], opts)
159+
158160
with {:ok, %{"operationTime" => op_time,
159161
"cursor" => %{"id" => new_cursor_id,
160162
"nextBatch" => docs} = cursor,
@@ -172,8 +174,9 @@ defmodule Mongo.Cursor do
172174
{:ok, %{cursor_id: new_cursor_id, docs: docs, change_stream: change_stream}}
173175

174176
else
177+
{:error, %Mongo.Error{code: code} = not_resumable} when code == 11601 or code == 136 or code == 237 -> {:error, not_resumable}
175178
{:error, _error} ->
176-
# todo: examing the error details
179+
177180
with {:ok, wire_version} <- Mongo.wire_version(conn, opts) do
178181

179182
[%{"$changeStream" => stream_opts} | pipeline] = Keyword.get(aggregate_cmd, :pipeline) # extract the change stream options

0 commit comments

Comments
 (0)