{"record":{"id":"e32a47b6a99763f1","repo":"XX-net/XX-Net","slug":"remove-s-fail-r","errorCode":null,"errorMessage":"remove %s fail:%r","messagePattern":"remove (.+?) fail:%r","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/gae_proxy/local/ipv6_tunnel/common.py","lineNumber":43,"sourceCode":"        self.fd = open(log_file, \"a\")\n\n    def write(self, content):\n        self.fd.write(content + \"\\n\")\n        self.fd.flush()\n\n    def close(self):\n        self.fd.close()\n\n\npteredor_is_running = False\n\n\ndef new_pteredor(probe_nat=True):\n    if os.path.isfile(log_file):\n        try:\n            os.remove(log_file)\n        except Exception as e:\n            xlog.warn(\"remove %s fail:%r\", log_file, e)\n\n    global pteredor_is_running, usable\n    pteredor_is_running = probe_nat\n    prober = teredo_prober(probe_nat=probe_nat)\n\n    if prober.nat_type in ('cone', 'restricted'):\n        usable = 'usable'\n    elif prober.nat_type == 'offline':\n        usable = 'unusable'\n    else:\n        usable = 'unknown'\n\n    if probe_nat:\n        pteredor_is_running = False\n        log = Log()\n        log.write('qualified: %s\\nNAT type: %s' % (prober.qualified, prober.nat_type))\n        log.close()\n    return prober","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/gae_proxy/local/ipv6_tunnel/common.py#L25-L61","documentation":"While starting the Teredo IPv6 tunnel prober, the proxy tried to delete a stale log file (log_file) and the OS remove() call failed. The failure is only logged with xlog.warn; probing continues, so it is non-fatal noise in the ipv6_tunnel common path.","triggerScenarios":"new_pteredor() finds log_file exists on disk, calls os.remove(log_file), and the remove raises — e.g. the file is locked by another process, has wrong permissions, or the teredo process still holds it open on Windows.","commonSituations":"Windows file locking when a previous miredo/teredo instance is still running; antivirus holding the log; running without delete permission in the working directory; two proxy instances started concurrently.","solutions":["Stop the other running XX-Net/teredo instance so the file lock is released","Manually delete the stale log file once, then restart","Run the proxy with permissions allowing deletion in its working/log directory","Ignore the warning if IPv6 probing still succeeds (check subsequent nat_type result)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os\nif os.path.exists(log_file):\n    try:\n        with open(log_file): pass  # probe lockability cheaply (best effort)\n    except IOError:\n        pass  # will warn on remove; acceptable","typeGuard":null,"tryCatchPattern":"try:\n    new_pteredor(probe_nat=True)\nexcept Exception:\n    ipv6_tunnel.disable()  # fall back to IPv4 direct","preventionTips":["Ensure only one proxy instance runs at a time","Run with delete permissions in the log directory","Clean stale teredo logs on startup before probing"],"tags":["ipv6","teredo","file-io","windows"],"backgroundTag":"file-delete-permission-denied","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}