Skip to content

Is circular option expected to work with rails mode and ActiveSupport loaded ? #981

@lioneldebauge

Description

@lioneldebauge

Hello 👋

While using Oj I found out it was not able to handle circular references when ActiveSupport was loaded in rails mode. I was wondering if this was expected. I could not find a mention of this special case in the documentation at least.

require("bundler/inline")

gemfile do
  source("https://rubygems.org")
  gem("oj", "3.16.11")
  gem("activesupport", "8.0.3")
end

require("oj")
require("active_support/all")

begin
  a = []
  b = []
  a.push(b)
  b.push(a)
  Oj.dump(a, mode: :rails, circular: true)
  puts("SUCCESS: handled circular reference with circular: true")
rescue SystemStackError
  puts("ERROR: SystemStackError triggered because of circular reference")
end

Thanks a lot for any help you can give me 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions