realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.32k stars 2.15k forks source link

Sample code from Quick Start section produces error in console log #8166

Open Gargo opened 1 year ago

Gargo commented 1 year ago

How frequently does the bug occur?

Always

Description

I just try to create realm database from your quick start and write something to this database: https://www.mongodb.com/docs/realm/sdk/swift/quick-start/ But even this simple code produces strange errors in console log

Stacktrace & log output

2023-03-13 11:09:14.269102+0300 TestRealm[56847:824997] Task <E9B2CB4F-27E1-44B6-8F20-9422342C1FDB>.<2> HTTP load failed, 1708/0 bytes (error code: -1017 [4:-1])
2023-03-13 11:09:14.272633+0300 TestRealm[56847:824997] Task <E9B2CB4F-27E1-44B6-8F20-9422342C1FDB>.<2> finished with error [-1017] Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo={_kCFStreamErrorCodeKey=-1, NSUnderlyingError=0x600001979560 {Error Domain=kCFErrorDomainCFNetwork Code=-1017 "(null)" UserInfo={_kCFStreamErrorCodeKey=-1, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E9B2CB4F-27E1-44B6-8F20-9422342C1FDB>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <E9B2CB4F-27E1-44B6-8F20-9422342C1FDB>.<2>"
), NSLocalizedDescription=cannot parse response, NSErrorFailingURLStringKey=https://data.mongodb-api.com/app/realmsdkmetrics-zmhtm/endpoint/metric_webhook/metric?data=eyJldmVudCI6IlJ1biIsInByb3BlcnRpZXMiOnsiZGlzdGluY3RfaWQiOiIwZDUxNDUzNDEyYzIxNjdhMGQwZjhiNzJlNzMwNmU0OWZiNTMyODg2OTA2MzE5NzViM2ExZjA4MzAwYWVkZWNlIiwiVGFyZ2V0IE9TIFZlcnNpb24iOiJWZXJzaW9uIDE2LjIgKEJ1aWxkIDIwQzUyKSIsIkNsYW5nIFZlcnNpb24iOiIxNC4wLjAgKGNsYW5nLTE0MDAuMC4yOS4yM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ZjIwMDY2ZDM0NWQzNjBmZDAiLCJBbm9ueW1pemVkIEJ1bmRsZSBJRCI6IjFiODhjMDMxYWNiYzQ2MzFkOGJjZTI1NjhiODhhMjBjZTA3N2U2NmQzYjFkNzU5N2JlMTA3OWFiYTUyMWUyMGYiLCJUYXJnZXQgT1MgVHlwZSI6ImlvcyIsIkJpbmRpbmciOiJjb2NvYSIsIlJlYWxtIFZlcnNpb24iOiIxMC4zNy4wIiwiQ2xhbmcgTWFqb3IgVmVyc2lvbiI6MTQsIkluc3RhbGxhdGlvbiBNZXRob2QiOiJDb2NvYVBvZHMiLCJUYXJnZXQgT1MgTWluaW11bSBWZXJzaW9uIjoiMTYuMiIsIkFub255bWl6ZWQgTUFDIEFkZHJlc3MiOiIwZDUxNDUzNDEyYzIxNjdhMGQwZjhiNzJlNzMwNmU0OWZiNTMyODg2OTA2MzE5NzViM2ExZjA4MzAwYWVkZWNlIiwiSG9zdCBPUyBUeXBlIjoib3N4In19, _kCFStreamErrorDomainKey=4}

Can you reproduce the bug?

Always

Reproduction Steps

I just create a sample app with storyboards, connect RealmSwift through Cocoapods and change ViewController's code to the following:

import UIKit
import RealmSwift

class Todo: Object {
   @Persisted(primaryKey: true) var _id: ObjectId
   @Persisted var name: String = ""
   @Persisted var status: String = ""
   @Persisted var ownerId: String
   convenience init(name: String, ownerId: String) {
       self.init()
       self.name = name
       self.ownerId = ownerId
   }
}

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        let realm = try! Realm()
        let todo = Todo(name: "Do laundry", ownerId: "user.id")
        try! realm.write {
            realm.add(todo)
        }
    }
}

Version

10.37.0

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 16.2 (simulator)

Build environment

Xcode version: 14.2 Dependency manager and version: Cocoapods 1.12.0

dianaafanador3 commented 1 year ago

Hi @Gargo this should be fixed by now, let us know if you still get the error message.

Gargo commented 1 year ago

@dianaafanador3 I posted a bug. Then you didn't fix it (no commits) but immediately wrote to confirm if the error message persists. What do you mean?

dianaafanador3 commented 1 year ago

@Gargo This is something that is not code related, this is something in our backend where we track some debug metrics to ensure a better developer experience. I tested this and seems like the backend is not returning this error anymore, if you still see it, please let us know.

Gargo commented 1 year ago

@dianaafanador3 I confirm this issue persists. How to disable these logs if they don't work properly?

Jaycyn commented 1 year ago

I can confirm a local only Realm project using the above code compiles and works correctly with no errors at this time.

Gargo commented 1 year ago

@Jaycyn in my case it compiles and works to but shows these inner realm errors. Does it depend on cpu (m2)?

Jaycyn commented 1 year ago

@Gargo I don't believe so. It's working on both Intel and Apple Silicon for me, and am not seeing any error, inner or otherwise.

dianaafanador3 commented 1 year ago

@Gargo it seems like an error parsing the metrics data we send to our backend, which could be caused from something specific to your environment, causing the data not be parsed correctly. The only way we can check this will be with an example of the payload. If you can send this to us that will be very helpful. Have in mind that the console log error doesn't mean that there is an issue on the realm or anything related to your data, and everything should be working fine.

Gargo commented 1 year ago

@dianaafanador3 how to do that?

dianaafanador3 commented 1 year ago

I actually was able to read this in our side, and this is caused by a no-common character which is not been encoded correctly and causing the error on our server, most probably is caused because your computer is in a language which is not completely supported, we'll take a look at this. Again, have in mind that the console log error doesn't mean that there is an issue on the realm or anything related to your data, and everything is working fine.

null-z commented 1 year ago

I have the same problem with console log.

Console log 2023-05-16 11:34:34.221914+0300 AwGeez[67288:11681600] Task <26B6DFAB-A7B2-4728-85B2-1CD66904D6C7>.<2> HTTP load failed, 1740/0 bytes (error code: -1017 [4:-1]) 2023-05-16 11:34:34.225791+0300 AwGeez[67288:11681600] Task <26B6DFAB-A7B2-4728-85B2-1CD66904D6C7>.<2> finished with error [-1017] Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo={_kCFStreamErrorCodeKey=-1, NSUnderlyingError=0x600001d51ef0 {Error Domain=kCFErrorDomainCFNetwork Code=-1017 "(null)" UserInfo={_kCFStreamErrorCodeKey=-1, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <26B6DFAB-A7B2-4728-85B2-1CD66904D6C7>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <26B6DFAB-A7B2-4728-85B2-1CD66904D6C7>.<2>" ), NSLocalizedDescription=cannot parse response, NSErrorFailingURLStringKey=https://data.mongodb-api.com/app/realmsdkmetrics-zmhtm/endpoint/metric_webhook/metric?data=eyJldmVudCI6IlJ1biIsInByb3BlcnRpZXMiOnsiZGlzdGluY3RfaWQiOiJkOTEzMjIzZWM1MGU4NDg1ZWI3YTBmYmQyMjhiNjQ0OGFiYzYzNDQwZTE4MjNiZWUwZTYyZGNiOTA3NjJmZmJlIiwiVGFyZ2V0IE9TIFZlcnNpb24iOiJWZXJzaW9uIDE2LjQgKEJ1aWxkIDIwRTI0NykiLCJDbGFuZyBWZXJzaW9uIjoiMTQuMC4zIChjbGFuZy0xNDAzLjAuMjIuMTQuMSkiLCJIb3N0IE9TIFZlcnNpb24iOiIyMi4xLjAiLCJMYW5ndWFnZSI6InN3aWZ0IiwidG9rZW4iOiJjZTBmYWMxOTUwOGY2YzhmMjAwNjZkMzQ1ZDM2MGZkMCIsIkFub255bWl6ZWQgQnVuZGxlIElEIjoiODg3NzBmNDk5ODVlNzNiNTcyMTc0ZmVmMzViMzYxMzE3ZTNiMDY3YThlMjVlMmUzNmYyZTA3MDA1ZjRmOWFlOCIsIlRhcmdldCBPUyBUeXBlIjoiaW9zIiwiQmluZGluZyI6ImNvY29hIiwiUmVhbG0gVmVyc2lvbiI6IjEwLjM5LjEiLCJDbGFuZyBNYWpvciBWZXJzaW9uIjoxNCwiSW5zdGFsbGF0aW9uIE1ldGhvZCI6IlN3aWZ0IFBhY2thZ2UgTWFuYWdlciIsIlRhcmdldCBPUyBNaW5pbXVtIFZlcnNpb24iOiIxMy4wIiwiQW5vbnltaXplZCBNQUMgQWRkcmVzcyI6ImQ5MTMyMjNlYzUwZTg0ODVlYjdhMGZiZDIyOGI2NDQ4YWJjNjM0NDBlMTgy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}
dianaafanador3 commented 1 year ago

@null-z which language do you have setup in your Mac?

null-z commented 1 year ago

@dianaafanador3 English

dianaafanador3 commented 1 year ago

On which target OS are you running your App when this log?, Can you please share it?, you can get this by running po ProcessInfo.processInfo.operatingSystemVersion on your Xcode console, while running the App.

null-z commented 1 year ago

@dianaafanador3

simulator iPhone 14 Pro Max iOS 16.4 (lldb) po ProcessInfo.processInfo.operatingSystemVersion ▿ NSOperatingSystemVersion - majorVersion : 16 - minorVersion : 4 - patchVersion : 0
device iPhone 6s iOS 15.7.5 (lldb) po ProcessInfo.processInfo.operatingSystemVersion ▿ NSOperatingSystemVersion - majorVersion : 15 - minorVersion : 7 - patchVersion : 5

Also on the device the logs are slightly different

device log 2023-05-16 21:42:46.440004+0300 AwGeez[33591:1298635] [tcp] tcp_input [C1.1.1:3] flags=[R] seq=1184012397, ack=0, win=0 state=LAST_ACK rcv_nxt=1184012397, snd_una=3994937804 2023-05-16 21:42:46.440296+0300 AwGeez[33591:1298635] [tcp] tcp_input [C1.1.1:3] flags=[R] seq=1184012397, ack=0, win=0 state=CLOSED rcv_nxt=1184012397, snd_una=3994937804 2023-05-16 21:42:46.814299+0300 AwGeez[33591:1298639] [tcp] tcp_input [C3.1.1:3] flags=[R] seq=476462894, ack=0, win=0 state=LAST_ACK rcv_nxt=476462894, snd_una=3862334869 2023-05-16 21:42:46.817866+0300 AwGeez[33591:1298639] [tcp] tcp_input [C3.1.1:3] flags=[R] seq=476462894, ack=0, win=0 state=CLOSED rcv_nxt=476462894, snd_una=3862334869 2023-05-16 21:42:47.128230+0300 AwGeez[33591:1298635] Task <0DF9A562-4E11-41F2-B98F-4C627D891E3B>.<1> HTTP load failed, 1482/0 bytes (error code: -1017 [4:-1]) 2023-05-16 21:42:47.134260+0300 AwGeez[33591:1298635] Task <0DF9A562-4E11-41F2-B98F-4C627D891E3B>.<1> finished with error [-1017] Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo={_kCFStreamErrorCodeKey=-1, NSUnderlyingError=0x2800c4030 {Error Domain=kCFErrorDomainCFNetwork Code=-1017 "(null)" UserInfo={_kCFStreamErrorCodeKey=-1, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0DF9A562-4E11-41F2-B98F-4C627D891E3B>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <0DF9A562-4E11-41F2-B98F-4C627D891E3B>.<1>" ), NSLocalizedDescription=cannot parse response, NSErrorFailingURLStringKey=https://data.mongodb-api.com/app/realmsdkmetrics-zmhtm/endpoint/metric_webhook/metric?data=eyJldmVudCI6IlJ1biIsInByb3BlcnRpZXMiOnsiZGlzdGluY3RfaWQiOiJ1bmtub3duIiwiVGFyZ2V0IE9TIFZlcnNpb24iOiJWZXJzaW9uIDE1LjcuNSAoQnVpbGQgMTlIMzMyKSIsIkNsYW5nIFZlcnNpb24iOiIxNC4wLjMgKGNsYW5nLTE0MDMuMC4yMi4xNC4xKSIsIkhvc3QgT1MgVmVyc2lvbiI6IjIxLjYuMCIsIkxhbmd1YWdlIjoic3dpZnQiLCJ0b2tlbiI6ImNlMGZhYzE5NTA4ZjZjOGYyMDA2NmQzNDVkMzYwZmQwIiwiQW5vbnltaXplZCBCdW5kbGUgSUQiOiI4ODc3MGY0OTk4NWU3M2I1NzIxNzRmZWYzNWIzNjEzMTdlM2IwNjdhOGUyNWUyZTM2ZjJlMDcwMDVmNGY5YWU4IiwiVGFyZ2V0IE9TIFR5cGUiOiJpb3MiLCJCaW5kaW5nIjoiY29jb2EiLCJSZWFsbSBWZXJzaW9uIjoiMTAuMzkuMSIsIkNsYW5nIE1ham9yIFZlcnNpb24iOjE0LCJJbnN0YWxsYXRpb24gTWV0aG9kIjoiU3dpZnQgUGFja2FnZSBNYW5hZ2VyIiwiVGFyZ2V0IE9TIE1pbmltdW0gVmVyc2lvbiI6IjEzLjAiLCJBbm9ueW1pemVkIE1BQyBBZGRyZXNzIjoidW5rbm93biIsIkhvc3QgT1MgVHlwZSI6Im9zeCJ9fQ==, NSErrorFailingURLKey=https://data.mongodb-api.com/app/realmsdkmetrics-zmhtm/endpoint/metric_webhook/metric?data=eyJldmVudCI6IlJ1biIsInByb3BlcnRpZXMiOnsiZGlzdGluY3RfaWQiOiJ1bmtub3duIiwiVGFyZ2V0IE9TIFZlcnNpb24iOiJWZXJzaW9uIDE1LjcuNSAoQnVpbGQgMTlIMzMyKSIsIkNsYW5nIFZlcnNpb24iOiIxNC4wLjMgKGNsYW5nLTE0MDMuMC4yMi4xNC4xKSIsIkhvc3QgT1MgVmVyc2lvbiI6IjIxLjYuMCIsIkxhbmd1YWdlIjoic3dpZnQiLCJ0b2tlbiI6ImNlMGZhYzE5NTA4ZjZjOGYyMDA2NmQzNDVkMzYwZmQwIiwiQW5vbnltaXplZCBCdW5kbGUgSUQiOiI4ODc3MGY0OTk4NWU3M2I1NzIxNzRmZWYzNWIzNjEzMTdlM2IwNjdhOGUyNWUyZTM2ZjJlMDcwMDVmNGY5YWU4IiwiVGFyZ2V0IE9TIFR5cGUiOiJpb3MiLCJCaW5kaW5nIjoiY29jb2EiLCJSZWFsbSBWZXJzaW9uIjoiMTAuMzkuMSIsIkNsYW5nIE1ham9yIFZlcnNpb24iOjE0LCJJbnN0YWxsYXRpb24gTWV0aG9kIjoiU3dpZnQgUGFja2FnZSBNYW5hZ2VyIiwiVGFyZ2V0IE9TIE1pbmltdW0gVmVyc2lvbiI6IjEzLjAiLCJBbm9ueW1pemVkIE1BQyBBZGRyZXNzIjoidW5rbm93biIsIkhvc3QgT1MgVHlwZSI6Im9zeCJ9fQ==, _kCFStreamErrorDomainKey=4} 2023-05-16 21:42:47.200178+0300 AwGeez[33591:1298643] [tcp] tcp_input [C4.1.1:3] flags=[R] seq=444443279, ack=0, win=0 state=LAST_ACK rcv_nxt=444443279, snd_una=236656257 2023-05-16 21:42:47.201230+0300 AwGeez[33591:1298643] [tcp] tcp_input [C4.1.1:3] flags=[R] seq=444443279, ack=0, win=0 state=CLOSED rcv_nxt=444443279, snd_una=236656257
ZefsAl commented 1 year ago

I'm using realm for the first time and when calling it I get an error.( let realm = try! Realm() Task <29112259-955B-4804-B7E2-641CEDBFADF1>.<2> HTTP load failed, 2752/0 bytes (error code: -1017 [4:-1])

Jaycyn commented 1 year ago

@ZefsAl Can you include more context to the error? That line of code

let realm = try! Realm()

Is a local only realm but the error code indicates you may be using a sync'd realm?

Can you supply a minimal code example and also include your versions of the os, Realm, cocoapods (if used) and Xcode?

Also, if you add a breakpoint and step through your code line by line, does it crash on that specific line or elsewhere.

Lastly, do you have sandboxing turned on?

ZefsAl commented 1 year ago

That's all I do: IOS App UIKit macOS Monterey 12.6.1 XCode 14/13

pod 'RealmSwift', '~>10' import RealmSwift let realm = try! Realm()

Everything seems to be working, I would like to know how to ignore/hide this error in the console (since it is quite large) I have attached the file, Thanks!

Error_Realm_1017.txt

Jaycyn commented 11 months ago

Just started getting this error again on a completely fresh project on a new Mac Studio

NSErrorFailingURLKey=https://data.mongodb-api.com/app/realmsdkmetrics-zmhtm/endpoint/metric_webhook/metric?data=...

Realm 10.44.0 macOS app SwiftUI macOS Sonoma 14.0 XCode 14 SPM to add Realm.